File tree 1 file changed +14
-9
lines changed
1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change 3
3
#include < string>
4
4
#include < direct.h>
5
5
#include < fstream>
6
-
6
+ # include < sys/stat.h >
7
7
#include " xboxkrnl.h"
8
8
9
9
namespace filesystem
10
10
{
11
11
void create_nested_dirs (const char *path)
12
12
{
13
+ if (!path || !*path)
14
+ return ;
15
+
13
16
char temp_path[256 ];
14
- strncpy (temp_path, path, sizeof (temp_path));
17
+ strncpy (temp_path, path, sizeof (temp_path) - 1 );
18
+ temp_path[sizeof (temp_path) - 1 ] = ' \0 ' ;
15
19
16
20
char *p = temp_path;
17
- while (*p)
21
+
22
+ // Skip leading drive letter (e.g., "C:\") or "game:\" prefix
23
+ if ((p[0 ] && p[1 ] == ' :' ) || strncmp (p, " game:\\ " , 6 ) == 0 )
24
+ p += (p[1 ] == ' :' ? 3 : 6 ); // Move past "C:\" or "game:\"
25
+
26
+ for (; *p; p++)
18
27
{
19
28
if (*p == ' \\ ' || *p == ' /' )
20
29
{
21
30
*p = ' \0 ' ;
22
-
23
- // Create the directory if it doesn't exist
24
- _mkdir (temp_path);
25
-
31
+ _mkdir (temp_path); // Attempt to create the directory
26
32
*p = ' \\ ' ;
27
33
}
28
- p++;
29
34
}
30
35
31
- _mkdir (temp_path);
36
+ _mkdir (temp_path); // Create final directory
32
37
}
33
38
34
39
/* *
You can’t perform that action at this time.
0 commit comments