12 #import <Foundation/Foundation.h>
24 struct stat stFileInfo;
25 if (stat(pathfilename.c_str(), &stFileInfo) == 0)
31 NSString* nsPath = [NSString stringWithCString:path.c_str()
32 encoding:[NSString defaultCStringEncoding]];
33 NSString* nsFile = [NSString stringWithCString:file.c_str()
34 encoding:[NSString defaultCStringEncoding]];
36 NSFileManager* fileManager = [NSFileManager defaultManager];
37 if ([fileManager fileExistsAtPath:nsPath])
40 [fileManager fileExistsAtPath:nsPath isDirectory:(&isDir)];
44 contents = [fileManager contentsOfDirectoryAtPath:nsPath error:nil];
47 for (NSString* entity in contents)
51 if ([entity length] == [nsFile length])
53 if ([entity caseInsensitiveCompare:nsFile] == NSOrderedSame)
56 pathfilename = path + [entity UTF8String];
68 vector<string> folderContent;
74 NSString* nsPath = [NSString stringWithCString:path.c_str()
75 encoding:[NSString defaultCStringEncoding]];
76 [NSString stringWithCString:folder.c_str() encoding:[NSString defaultCStringEncoding]];
78 NSFileManager* fileManager = [NSFileManager defaultManager];
80 if ([fileManager fileExistsAtPath:nsPath])
83 [fileManager fileExistsAtPath:nsPath isDirectory:(&isDir)];
88 contents = [fileManager contentsOfDirectoryAtPath:nsPath error:nil];
90 for (NSString* entity in contents)
93 folderContent.emplace_back(path + [entity UTF8String]);
95 folderContent.emplace_back([entity UTF8String]);
105 NSArray* paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
108 NSString* libraryDirectory = [paths objectAtIndex:0];
109 string configDir = [libraryDirectory UTF8String];
110 configDir +=
"/SLProject";
111 NSString* configPath = [NSString stringWithUTF8String:configDir.c_str()];
115 if (![[NSFileManager defaultManager] fileExistsAtPath:configPath])
116 [[NSFileManager defaultManager] createDirectoryAtPath:configPath
117 withIntermediateDirectories:NO
121 return configDir +
"/";
128 NSString* bundlePath = [[NSBundle mainBundle] resourcePath];
129 string cwd = [bundlePath UTF8String];
136 return remove(pathfilename.c_str()) != 0;
static bool deleteFile(std::string &pathfilename)
Deletes a file on the filesystem.
static std::vector< std::string > getAllNamesInDir(const std::string &dirName, bool fullPath=true)
Returns all files and folders in a directory as a vector.
static std::string getCurrentWorkingDir()
Returns the working directory.
static bool fileExists(std::string &pathfilename)
Returns true if a file exists.
static std::string getAppsWritableDir()
Returns the writable configuration directory.
string getFileName(const string &pathFilename)
Returns the filename of path-filename string.
string getPath(const string &pathFilename)
Returns the path w. '\' of path-filename string.