3 * Example program to create a folder on the device.
5 * Copyright (C) 2006-2009 Linus Walleij <triad@df.lth.se>
6 * Copyright (C) 2006 Chris A. Debenham <chris@adebenham.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
27 #include "pathutils.h"
30 extern LIBMTP_folder_t *folders;
31 extern LIBMTP_file_t *files;
32 extern LIBMTP_mtpdevice_t *device;
34 int newfolder_command (int argc, char **argv)
39 printf("Usage: newfolder name <parent> <storage>\n");
40 printf(" parent = parent folder or 0 to create the new folder in the root dir\n");
41 printf(" storage = storage id or 0 to create the new folder on the primary storage\n");
45 newid = LIBMTP_Create_Folder(device, argv[1], atol(argv[2]), atol(argv[3]));
47 printf("Folder creation failed.\n");
50 printf("New folder created with ID: %d\n", newid);
56 newfolder_function(char * path)
58 printf("Creating new folder %s\n",path);
59 char * parent = dirname(path);
60 char * folder = basename(path);
61 int id = parse_path (parent,files,folders);
62 int newid = LIBMTP_Create_Folder(device, folder, id, 0);
64 printf("Folder creation failed.\n");
65 LIBMTP_Dump_Errorstack(device);
66 LIBMTP_Clear_Errorstack(device);
69 printf("New folder created with ID: %d\n", newid);