JX Application Framework
|
#include "jDirUtil.h"
#include "jFileUtil.h"
#include "JDirInfo.h"
#include "JLatentPG.h"
#include "JStringIterator.h"
#include "jGlobals.h"
#include <limits.h>
#include "jAssert.h"
Functions | |
bool | JIsRelativePath (const JString &path) |
JError | JRenameDirectory (const JString &oldName, const JString &newName) |
JString | JGetUniqueDirEntryName (const JString &path, const JString &namePrefix, const JUtf8Byte *nameSuffix, const JIndex startIndex) |
JString | JGetPermissionsString (const mode_t mode) |
JString | JGetClosestDirectory (const JString &origDirName, const bool requireWrite, const JString *basePath) |
bool | JSearchSubdirs (const JString &startPath, const JString &name, const bool isFile, const JString::Case caseSensitive, JString *path, JString *newName, JProgressDisplay *userPG, bool *userCancelled) |
JString | JConvertToHomeDirShortcut (const JString &path) |
If the directory is below the user's home directory, converts the given path to start with ~. Otherwise, returns the input string.
JString JGetClosestDirectory | ( | const JString & | origDirName, |
const bool | requireWrite, | ||
const JString * | basePath | ||
) |
If the directory does not exist, go as far down the directory tree as possible towards the specified directory.
As an example, /usr/include/junk doesn't normally exist, so it will return /usr/include.
If a partial path is passed in, it is assumed to be relative to the given basePath. If this is empty, the current working directory is used instead. If the base path is valid, a partial path will be returned.
If the path begins with ~ and the home directory exists, a ~ path will be returned.
JString JGetPermissionsString | ( | const mode_t | mode | ) |
Converts the low 9 bits of the st_mode field from stat() to a string using the same format as ls.
JString JGetUniqueDirEntryName | ( | const JString & | path, |
const JString & | namePrefix, | ||
const JUtf8Byte * | nameSuffix, | ||
const JIndex | startIndex | ||
) |
Just like tmpnam, this function is not safe, because it does not perform atomic check-create. The safe functions are JCreateTempDirectory() and JCreateTempFile().
Returns a unique name, starting with namePrefix, for use in the specified directory. If path is empty, it tries to use /tmp. If this fails, it uses the current working directory.
nameSuffix can be nullptr.
We ignore the possibility of not finding a valid name because the file system will fill up long before we run out of possibilities.
startIndex lets you optimize when creating a large number of temporary files. By setting startIndex to the number of files that you have already created, you make the process of generating the file names O(N) instead of O(N^2).
Renames the specified directory.
bool JSearchSubdirs | ( | const JString & | startPath, |
const JString & | name, | ||
const bool | isFile, | ||
const JString::Case | caseSensitive, | ||
JString * | path, | ||
JString * | newName, | ||
JProgressDisplay * | userPG, | ||
bool * | userCancelled | ||
) |