SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
Utils_iOS Class Reference

SLFileSystem provides basic filesystem functions. More...

#include <Utils_iOS.h>

Static Public Member Functions

static bool fileExists (std::string &pathfilename)
 Returns true if a file exists. More...
 
static std::vector< std::string > getAllNamesInDir (const std::string &dirName, bool fullPath=true)
 Returns all files and folders in a directory as a vector. More...
 
static std::string getAppsWritableDir ()
 Returns the writable configuration directory. More...
 
static std::string getAppsDocumentsDir ()
 Returns the writable documents directory. More...
 
static std::string getCurrentWorkingDir ()
 Returns the working directory. More...
 
static bool deleteFile (std::string &pathfilename)
 Deletes a file on the filesystem. More...
 
static bool fileExists (std::string &pathfilename)
 Returns true if a file exists. More...
 
static std::vector< std::string > getAllNamesInDir (const std::string &dirName)
 Returns all files and folders in a directory as a vector. More...
 
static std::string getAppsWritableDir ()
 Returns the writable configuration directory. More...
 
static std::string getCurrentWorkingDir ()
 Returns the working directory. More...
 
static bool deleteFile (std::string &pathfilename)
 Deletes a file on the filesystem. More...
 

Detailed Description

SLFileSystem provides basic filesystem functions.

Definition at line 16 of file modules/utils/source/Utils_iOS.h.

Member Function Documentation

◆ deleteFile() [1/2]

static bool Utils_iOS::deleteFile ( std::string &  pathfilename)
static

Deletes a file on the filesystem.

◆ deleteFile() [2/2]

bool Utils_iOS::deleteFile ( std::string &  pathfilename)
static

Deletes a file on the filesystem.

Definition at line 133 of file modules/utils/source/Utils_iOS.mm.

134 {
135  if (Utils_iOS::fileExists(pathfilename))
136  return remove(pathfilename.c_str()) != 0;
137  return false;
138 }
static bool fileExists(std::string &pathfilename)
Returns true if a file exists.

◆ fileExists() [1/2]

static bool Utils_iOS::fileExists ( std::string &  pathfilename)
static

Returns true if a file exists.

◆ fileExists() [2/2]

static bool Utils_iOS::fileExists ( std::string &  pathfilename)
static

Returns true if a file exists.

◆ getAllNamesInDir() [1/2]

static std::vector<std::string> Utils_iOS::getAllNamesInDir ( const std::string &  dirName)
static

Returns all files and folders in a directory as a vector.

◆ getAllNamesInDir() [2/2]

static std::vector<std::string> Utils_iOS::getAllNamesInDir ( const std::string &  dirName,
bool  fullPath = true 
)
static

Returns all files and folders in a directory as a vector.

◆ getAppsDocumentsDir()

static std::string Utils_iOS::getAppsDocumentsDir ( )
static

Returns the writable documents directory.

◆ getAppsWritableDir() [1/2]

static std::string Utils_iOS::getAppsWritableDir ( )
static

Returns the writable configuration directory.

◆ getAppsWritableDir() [2/2]

std::string Utils_iOS::getAppsWritableDir ( )
static

Returns the writable configuration directory.

Definition at line 102 of file modules/utils/source/Utils_iOS.mm.

103 {
104  // Get library directory for config file
105  NSArray* paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
106  NSUserDomainMask,
107  YES);
108  NSString* libraryDirectory = [paths objectAtIndex:0];
109  string configDir = [libraryDirectory UTF8String];
110  configDir += "/SLProject";
111  NSString* configPath = [NSString stringWithUTF8String:configDir.c_str()];
112 
113  // Create if it does not exist
114  NSError* error;
115  if (![[NSFileManager defaultManager] fileExistsAtPath:configPath])
116  [[NSFileManager defaultManager] createDirectoryAtPath:configPath
117  withIntermediateDirectories:NO
118  attributes:nil
119  error:&error];
120 
121  return configDir + "/";
122 }

◆ getCurrentWorkingDir() [1/2]

static std::string Utils_iOS::getCurrentWorkingDir ( )
static

Returns the working directory.

◆ getCurrentWorkingDir() [2/2]

std::string Utils_iOS::getCurrentWorkingDir ( )
static

Returns the working directory.

Definition at line 124 of file modules/utils/source/Utils_iOS.mm.

125 {
126  // Get the main bundle path and pass it the SLTexture and SLShaderProg
127  // This will be the default storage location for textures and shaders
128  NSString* bundlePath = [[NSBundle mainBundle] resourcePath];
129  string cwd = [bundlePath UTF8String];
130  return cwd + "/";
131 }

The documentation for this class was generated from the following files: