-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathFileSystemOsX.mm
More file actions
53 lines (47 loc) · 1.23 KB
/
Copy pathFileSystemOsX.mm
File metadata and controls
53 lines (47 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "StdAfx.h"
#if __APPLE__
#include "FileSystem.h"
#include <CoreServices/CoreServices.h>
#include <Foundation/Foundation.h>
std::string GetAppdataFolder()
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSApplicationSupportDirectory, NSUserDomainMask, YES );
return paths.count && paths.firstObject ? [paths.firstObject UTF8String] : "";
}
bool CreateDirectoryRec(const wchar_t* dir) {
if ( !mkdir( CW2A( dir ), ACCESSPERMS ) )
{
return true;
}
if (errno == EEXIST)
{
return true;
}
// find the last separator
std::wstring full(dir);
std::wstring::size_type s = full.find_last_of(L"/\\");
if (s != std::wstring::npos)
{
std::wstring pre = full.substr(0, s);
if (!CreateDirectoryRec(pre.c_str()))
{
return false;
}
return !mkdir( CW2A( dir ), ACCESSPERMS );
}
return false;
}
const std::wstring& GetLogsFolder()
{
static std::wstring result;
if( result.empty() )
{
std::wstring appDataFolder = (const wchar_t *) CA2W( GetAppdataFolder().c_str() );
if( !appDataFolder.empty() )
{
result = appDataFolder + L"/CCP/EVE";
}
}
return result;
}
#endif