mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Create any parent directory required for log file
This commit is contained in:
@@ -736,6 +736,8 @@ void RenderDoc::SetLogFile(const char *logFile)
|
||||
|
||||
if(m_LogFile.substr(m_LogFile.length()-4) == ".rdc")
|
||||
m_LogFile = m_LogFile.substr(0, m_LogFile.length()-4);
|
||||
|
||||
FileIO::CreateParentDirectory(m_LogFile);
|
||||
}
|
||||
|
||||
void RenderDoc::SetProgress(LoadProgressSection section, float delta)
|
||||
|
||||
@@ -145,6 +145,30 @@ namespace FileIO
|
||||
return ret + filename;
|
||||
}
|
||||
|
||||
void CreateParentDirectory(const string &filename)
|
||||
{
|
||||
string fn = dirname(filename);
|
||||
|
||||
// want trailing slash so that we create all directories
|
||||
fn.push_back('/');
|
||||
|
||||
if(fn[0] != '/')
|
||||
return;
|
||||
|
||||
size_t offs = fn.find('/', 1);
|
||||
|
||||
while(offs != string::npos)
|
||||
{
|
||||
// create directory path from 0 to offs by NULLing the
|
||||
// / at offs, mkdir, then set it back
|
||||
fn[offs] = 0;
|
||||
mkdir(fn.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
fn[offs] = '/';
|
||||
|
||||
offs = fn.find_first_of('/', offs+1);
|
||||
}
|
||||
}
|
||||
|
||||
string GetFullPathname(const string &filename)
|
||||
{
|
||||
char path[512] = {0};
|
||||
|
||||
@@ -177,6 +177,8 @@ namespace FileIO
|
||||
string GetAppFolderFilename(const string &filename);
|
||||
string GetReplayAppFilename();
|
||||
|
||||
void CreateParentDirectory(const string &filename);
|
||||
|
||||
string GetFullPathname(const string &filename);
|
||||
|
||||
void GetExecutableFilename(string &selfName);
|
||||
|
||||
@@ -170,6 +170,20 @@ namespace FileIO
|
||||
return StringFormat::Wide2UTF8(wstring(path));
|
||||
}
|
||||
|
||||
void CreateParentDirectory(const string &filename)
|
||||
{
|
||||
wstring wfn = StringFormat::UTF82Wide(filename);
|
||||
|
||||
wfn = dirname(wfn);
|
||||
|
||||
// This function needs \\s not /s. So stupid!
|
||||
for(size_t i=0; i < wfn.size(); i++)
|
||||
if(wfn[i] == L'/')
|
||||
wfn[i] = L'\\';
|
||||
|
||||
SHCreateDirectoryExW(NULL, wfn.c_str(), NULL);
|
||||
}
|
||||
|
||||
string GetReplayAppFilename()
|
||||
{
|
||||
HMODULE hModule = NULL;
|
||||
|
||||
Reference in New Issue
Block a user