Author: kalim
Date: 2005-08-07 01:25:25 +0000 (Sun, 07 Aug 2005)
New Revision: 9169

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9169

Log:
Added mkdir (with support for recursion) and enabled the recurse command.
-Kalim
Modified:
   branches/SOC/SAMBA_3_0/source/client/client.c


Changeset:
Modified: branches/SOC/SAMBA_3_0/source/client/client.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/client/client.c       2005-08-06 23:41:18 UTC 
(rev 9168)
+++ branches/SOC/SAMBA_3_0/source/client/client.c       2005-08-07 01:25:25 UTC 
(rev 9169)
@@ -1081,21 +1081,13 @@
 
 static BOOL do_mkdir(char *name)
 {
-       struct cli_state *targetcli;
-       pstring targetname;
-       
-       if ( !cli_resolve_path( "", cli, name, &targetcli, targetname ) ) {
-               d_printf("mkdir %s: %s\n", name, cli_errstr(cli));
-               return False;
-       }
-
-       if (!cli_mkdir(targetcli, targetname)) {
-               d_printf("%s making remote directory %s\n",
-                        cli_errstr(targetcli),name);
-               return(False);
-       }
-
-       return(True);
+       if (smbc_mkdir(name, 755) < 0)
+    {
+        DEBUG(2, ("Error: %s making remote directory %s\n", strerror(errno), 
name));
+        return False;
+    }
+    
+       return True;
 }
 
 /****************************************************************************
@@ -1133,8 +1125,10 @@
 
 static int cmd_mkdir(void)
 {
+    int dh;
        pstring mask;
        pstring buf;
+    pstring targetname;
        char *p=buf;
   
        pstrcpy(mask,cur_dir);
@@ -1145,8 +1139,8 @@
                return 1;
        }
        pstrcat(mask,p);
-
-       if (recurse) {
+    
+    if (recurse) {
                pstring ddir;
                pstring ddir2;
                *ddir2 = 0;
@@ -1156,15 +1150,33 @@
                p = strtok(ddir,"/\\");
                while (p) {
                        pstrcat(ddir2,p);
-                       if (!cli_chkpath(cli, ddir2)) { 
-                               do_mkdir(ddir2);
-                       }
+            
+            pstrcpy(targetname, "smb:");
+            pstrcat(targetname, service);
+            pstrcat(targetname, "/");
+            pstrcat(targetname, ddir2);
+            DEBUG(3, ("Recursively making directory %s\n", targetname));
+            if ((dh = smbc_opendir(targetname)) < 0) {
+                if (!do_mkdir(targetname)) {
+                    d_printf("Error: %s making remote directory %s\n", 
strerror(errno), targetname);
+                    break;
+                }
+            }
+            else
+                smbc_closedir(dh);
+            
                        pstrcat(ddir2,"/");
                        p = strtok(NULL,"/\\");
-               }        
-       } else {
-               do_mkdir(mask);
+               }
        }
+    else {
+        pstrcpy(targetname, "smb:");
+        pstrcat(targetname, service);
+        pstrcat(targetname, mask);
+        
+        if (!do_mkdir(targetname))
+            d_printf("Error: %s making remote directory %s\n", 
strerror(errno), targetname);
+       }
        
        return 0;
 }
@@ -2774,9 +2786,9 @@
   {"lowercase",cmd_lowercase,"toggle lowercasing of filenames for 
get",{COMPL_NONE,COMPL_NONE}},  
 /*   {"ls",cmd_dir,"<mask> list the contents of the current 
directory",{COMPL_REMOTE,COMPL_NONE}},*/
 /*   {"mask",cmd_select,"<mask> mask all filenames against 
this",{COMPL_REMOTE,COMPL_NONE}}, */
-/*   {"md",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}}, 
*/
+  {"md",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
 /*   {"mget",cmd_mget,"<mask> get all the matching 
files",{COMPL_REMOTE,COMPL_NONE}}, */
-/*   {"mkdir",cmd_mkdir,"<directory> make a 
directory",{COMPL_NONE,COMPL_NONE}}, */
+  {"mkdir",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
 /*   {"more",cmd_more,"<remote name> view a remote file with your 
pager",{COMPL_REMOTE,COMPL_NONE}}, */  
 /*   {"mput",cmd_mput,"<mask> put all matching 
files",{COMPL_REMOTE,COMPL_NONE}}, */
   {"newer",cmd_newer,"<file> only mget files newer than the specified local 
file",{COMPL_LOCAL,COMPL_NONE}},
@@ -2789,7 +2801,7 @@
 /*   {"queue",cmd_queue,"show the print queue",{COMPL_NONE,COMPL_NONE}}, */
   {"quit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
   {"rd",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
-/*   {"recurse",cmd_recurse,"toggle directory recursion for mget and 
mput",{COMPL_NONE,COMPL_NONE}}, */  
+  {"recurse",cmd_recurse,"toggle directory recursion for mget and 
mput",{COMPL_NONE,COMPL_NONE}},
 /*  {"reget",cmd_reget,"<remote name> [local name] get a file restarting at 
end of local file",{COMPL_REMOTE,COMPL_LOCAL}},*/
 /*  {"rename",cmd_rename,"<src> <dest> rename some 
files",{COMPL_REMOTE,COMPL_REMOTE}},*/
 /*  {"reput",cmd_reput,"<local name> [remote name] put a file restarting at 
end of remote file",{COMPL_LOCAL,COMPL_REMOTE}},*/

Reply via email to