blob: 3c49ed9ba99f70a3215de47ae9be362d9225e1d4 [file] [log] [blame]
Linus Walleij9c6ca022006-04-21 10:24:15 +00001#include "common.h"
cjdebenh4a99f502006-11-09 22:03:05 +00002#include <libgen.h>
Linus Walleij9c6ca022006-04-21 10:24:15 +00003
cjdebenh4a99f502006-11-09 22:03:05 +00004void new_folder(char *);
5void newfolder(int,char **);
6
7extern LIBMTP_folder_t *folders;
8extern LIBMTP_file_t *files;
9extern LIBMTP_mtpdevice_t *device;
10
11void newfolder (int argc, char **argv)
Linus Walleij9c6ca022006-04-21 10:24:15 +000012{
Linus Walleijc86afbd2006-05-04 19:05:24 +000013 uint32_t newid;
Linus Walleij9c6ca022006-04-21 10:24:15 +000014
15 if(argc != 3) {
16 printf("Usage: newfolder name id\n");
Linus Walleijc86afbd2006-05-04 19:05:24 +000017 printf("(id = parent folder or 0 to create the new folder in the root dir)\n");
cjdebenh4a99f502006-11-09 22:03:05 +000018 return;
Linus Walleij9c6ca022006-04-21 10:24:15 +000019 }
20
Linus Walleijc86afbd2006-05-04 19:05:24 +000021 newid = LIBMTP_Create_Folder(device, argv[1], atol(argv[2]));
22 if (newid == 0) {
23 printf("Folder creation failed.\n");
24 } else {
25 printf("New folder created with ID: %d\n", newid);
26 }
cjdebenh4a99f502006-11-09 22:03:05 +000027}
Linus Walleij9c6ca022006-04-21 10:24:15 +000028
cjdebenh4a99f502006-11-09 22:03:05 +000029void
30new_folder(char * path)
31{
32 printf("Creating new folder %s\n",path);
33 char * parent = dirname(path);
34 char * folder = basename(path);
35 int id = parse_path (parent,files,folders);
36 int newid = LIBMTP_Create_Folder(device, folder, id);
37 if (newid == 0) {
38 printf("Folder creation failed.\n");
39 } else {
40 printf("New folder created with ID: %d\n", newid);
41 }
Linus Walleij9c6ca022006-04-21 10:24:15 +000042}
43