1313
1414#include "suppl.h"
1515#include "dfn.h"
16+ #ifdef DBCS
17+ # include "mbcs.h"
18+ #endif
1619
1720#include "../include/command.h"
1821#include "../include/misc.h"
2528#endif
2629
2730/* recursively delete subdirs and files */
31+ #ifdef DBCS
32+ int rmdir_withfiles (const char * fullname , char * path , int maxlen )
33+ #else
2834int rmdir_withfiles (char * path , int maxlen )
35+ #endif
2936{
3037 struct dos_ffblk f ;
3138 int ret ;
3239 int len = strlen (path ); /* Warning: we assume path is a buffer is large enough for longest file path */
3340 char * p = path + len ;
3441
3542 /* ensure ends with \ */
43+ #ifdef DBCS
44+ if (* fullname && * (CharPrev (fullname , p )) != '\\' )
45+ #else
3646 if (p [-1 ] != '\\' )
47+ #endif
3748 * p ++ = '\\' ;
3849 * p = '\0' ;
3950
@@ -60,7 +71,11 @@ int rmdir_withfiles(char * path, int maxlen)
6071
6172 strcpy (p , f .ff_name ); /* Make the full path */
6273 /* recursively delete subdirectory */
74+ #ifdef DBCS
75+ ret = rmdir_withfiles (fullname , path , maxlen );
76+ #else
6377 ret = rmdir_withfiles (path , maxlen );
78+ #endif
6479 }
6580 } while (!ret && (dos_findnext (& f ) == 0 ));
6681 dos_findclose (& f );
@@ -128,7 +143,11 @@ int recursive_rmdir(const char * path, int recursiveMode, int quiet)
128143 }
129144
130145 /* ensure ends with \ */
146+ #ifdef DBCS
147+ if (len > 0 && * (CharPrev (fullname , p )) != '\\' )
148+ #else
131149 if (p [-1 ] != '\\' )
150+ #endif
132151 * p ++ = '\\' ;
133152 * p = 0 ;
134153
@@ -141,8 +160,11 @@ int recursive_rmdir(const char * path, int recursiveMode, int quiet)
141160 return E_Other ;
142161 }
143162 }
144-
163+ #ifdef DBCS
164+ return rmdir_withfiles (fullname , fullname , sizeof (fullname ));
165+ #else
145166 return rmdir_withfiles (fullname , sizeof (fullname ));
167+ #endif
146168 } else {
147169 return rmdir (path );
148170 }
0 commit comments