MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / CreatePath

Function CreatePath

Libraries/unrar/filefn.cpp:41–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40
41bool CreatePath(const wchar *Path,bool SkipLastName)
42{
43 if (Path==NULL || *Path==0)
44 return false;
45
46#if defined(_WIN_ALL) || defined(_EMX)
47 uint DirAttr=0;
48#else
49 uint DirAttr=0777;
50#endif
51
52 bool Success=true;
53
54 for (const wchar *s=Path;*s!=0;s++)
55 {
56 wchar DirName[NM];
57 if (s-Path>=ASIZE(DirName))
58 break;
59
60 // Process all kinds of path separators, so user can enter Unix style
61 // path in Windows or Windows in Unix. s>Path check avoids attempting
62 // creating an empty directory for paths starting from path separator.
63 if (IsPathDiv(*s) && s>Path)
64 {
65#ifdef _WIN_ALL
66 // We must not attempt to create "D:" directory, because first
67 // CreateDirectory will fail, so we'll use \\?\D:, which forces Wine
68 // to create "D:" directory.
69 if (s==Path+2 && Path[1]==':')
70 continue;
71#endif
72 wcsncpy(DirName,Path,s-Path);
73 DirName[s-Path]=0;
74
75 Success=MakeDir(DirName,true,DirAttr)==MKDIR_SUCCESS;
76 if (Success)
77 {
78 mprintf(St(MCreatDir),DirName);
79 mprintf(L" %s",St(MOk));
80 }
81 }
82 }
83 if (!SkipLastName && !IsPathDiv(*PointToLastChar(Path)))
84 Success=MakeDir(Path,true,DirAttr)==MKDIR_SUCCESS;
85 return Success;
86}
87
88
89void SetDirTime(const wchar *Name,RarTime *ftm,RarTime *ftc,RarTime *fta)

Callers 6

ExtractHardlinkFunction · 0.85
FileCreateFunction · 0.85
CreateReparsePointFunction · 0.85
UnixSymlinkFunction · 0.85
ExtrCreateDirMethod · 0.85
ExtrCreateFileMethod · 0.85

Calls 5

IsPathDivFunction · 0.85
MakeDirFunction · 0.85
StFunction · 0.85
PointToLastCharFunction · 0.85
mprintfFunction · 0.70

Tested by

no test coverage detected