SysFileSystem Class Reference

#include <SysFileSystem.hpp>

Public Types

enum  { MaximumPathLength = MAXIMUM_PATH_LENGTH , MaximumFileNameLength = MAXIMUM_FILENAME_LENGTH , MaximumFileNameBuffer = MAXIMUM_PATH_LENGTH + MAXIMUM_FILENAME_LENGTH }
 
enum  { MaximumPathLength = MAXIMUM_PATH_LENGTH , MaximumFileNameLength = MAXIMUM_FILENAME_LENGTH , MaximumFileNameBuffer = MAXIMUM_PATH_LENGTH + MAXIMUM_FILENAME_LENGTH }
 

Static Public Member Functions

static const char * getTempFileName ()
 
static bool searchFileName (const char *name, char *fullName)
 
static void qualifyStreamName (const char *unqualifiedName, char *qualifiedName, size_t bufferSize)
 
static bool fileExists (const char *name)
 
static bool searchName (const char *name, const char *path, const char *extension, char *resolvedName)
 
static bool primitiveSearchName (const char *name, const char *path, const char *extension, char *resolvedName)
 
static bool checkCurrentFile (const char *name, char *resolvedName)
 
static bool searchPath (const char *name, const char *path, char *resolvedName)
 
static bool hasExtension (const char *name)
 
static bool hasDirectory (const char *name)
 
static bool canonicalizeName (char *name)
 
static bool normalizePathName (const char *name, char *resolved)
 
static RexxStringextractDirectory (RexxString *file)
 
static RexxStringextractExtension (RexxString *file)
 
static RexxStringextractFile (RexxString *file)
 
static bool deleteFile (const char *name)
 
static bool deleteDirectory (const char *name)
 
static bool isDirectory (const char *name)
 
static bool isReadOnly (const char *name)
 
static bool isWriteOnly (const char *name)
 
static bool isFile (const char *name)
 
static bool exists (const char *name)
 
static int64_t getLastModifiedDate (const char *name)
 
static uint64_t getFileLength (const char *name)
 
static bool makeDirectory (const char *name)
 
static bool moveFile (const char *oldName, const char *newName)
 
static bool isHidden (const char *name)
 
static bool setLastModifiedDate (const char *name, int64_t time)
 
static bool setFileReadOnly (const char *name)
 
static bool isCaseSensitive ()
 
static int getRoots (char *roots)
 
static const char * getSeparator ()
 
static const char * getPathSeparator ()
 
static const char * getTempFileName ()
 
static bool searchFileName (const char *name, char *fullName)
 
static void qualifyStreamName (const char *unqualifiedName, char *qualifiedName, size_t bufferSize)
 
static bool fileExists (const char *name)
 
static bool hasExtension (const char *name)
 
static bool hasDirectory (const char *name)
 
static RexxStringextractDirectory (RexxString *file)
 
static RexxStringextractExtension (RexxString *file)
 
static RexxStringextractFile (RexxString *file)
 
static bool searchName (const char *name, const char *path, const char *extension, char *resolvedName)
 
static bool primitiveSearchName (const char *name, const char *path, const char *extension, char *resolvedName)
 
static bool checkCurrentFile (const char *name, char *resolvedName)
 
static bool searchPath (const char *name, const char *path, const char *extension, char *resolvedName)
 
static void getLongName (char *fullName, size_t size)
 
static bool findFirstFile (const char *name)
 
static bool deleteFile (const char *name)
 
static bool deleteDirectory (const char *name)
 
static bool isDirectory (const char *name)
 
static bool isReadOnly (const char *name)
 
static bool isWriteOnly (const char *name)
 
static bool isFile (const char *name)
 
static bool exists (const char *name)
 
static int64_t getLastModifiedDate (const char *name)
 
static int64_t getFileLength (const char *name)
 
static bool makeDirectory (const char *name)
 
static bool moveFile (const char *oldName, const char *newName)
 
static bool isHidden (const char *name)
 
static bool setLastModifiedDate (const char *name, int64_t time)
 
static bool setFileReadOnly (const char *name)
 
static bool isCaseSensitive ()
 
static int getRoots (char *roots)
 
static const char * getSeparator ()
 
static const char * getPathSeparator ()
 

Static Public Attributes

static const char EOF_Marker = 0x1A
 
static const char * EOL_Marker = "\n"
 
static const char PathDelimiter = '/'
 
static int stdinHandle = 0
 
static int stdoutHandle = 1
 
static int stderrHandle = 2
 

Detailed Description

Definition at line 75 of file unix/SysFileSystem.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MaximumPathLength 
MaximumFileNameLength 
MaximumFileNameBuffer 

Definition at line 78 of file unix/SysFileSystem.hpp.

◆ anonymous enum

anonymous enum
Enumerator
MaximumPathLength 
MaximumFileNameLength 
MaximumFileNameBuffer 

Definition at line 56 of file windows/SysFileSystem.hpp.

Member Function Documentation

◆ canonicalizeName()

bool SysFileSystem::canonicalizeName ( char *  name)
static

Process a file name to add the current working directory or the home directory, as needed, then remove all of the . and .. elements.

Parameters
nameThe current working name.
Returns
true if this was valid enough to normalize.

Definition at line 572 of file unix/SysFileSystem.cpp.

References normalizePathName().

Referenced by checkCurrentFile(), qualifyStreamName(), searchFileName(), and searchPath().

◆ checkCurrentFile() [1/2]

bool SysFileSystem::checkCurrentFile ( const char *  name,
char *  resolvedName 
)
static

Try to locate a file using just the raw name passed in, as opposed to searching along a path for the name.

Parameters
nameThe name to use for the search.
Returns
An RexxString version of the file name, iff the file was located. Returns OREF_NULL if the file did not exist.

Definition at line 473 of file unix/SysFileSystem.cpp.

References canonicalizeName().

Referenced by primitiveSearchName().

◆ checkCurrentFile() [2/2]

static bool SysFileSystem::checkCurrentFile ( const char *  name,
char *  resolvedName 
)
static

◆ deleteDirectory() [1/2]

bool SysFileSystem::deleteDirectory ( const char *  name)
static

Delete a directory from the file system.

Parameters
nameThe name of the target directory.
Returns
The return code from the delete operation.

Definition at line 779 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ deleteDirectory() [2/2]

static bool SysFileSystem::deleteDirectory ( const char *  name)
static

◆ deleteFile() [1/2]

bool SysFileSystem::deleteFile ( const char *  name)
static

Delete a file from the file system.

Parameters
nameThe fully qualified name of the file.
Returns
The return code from the delete operation.

Definition at line 767 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ deleteFile() [2/2]

static bool SysFileSystem::deleteFile ( const char *  name)
static

◆ exists() [1/2]

bool SysFileSystem::exists ( const char *  name)
static

Test if a file exists using a fully qualified name.

Parameters
nameThe target file name.
Returns
True if the file exists, false if it is unknown.

Definition at line 854 of file unix/SysFileSystem.cpp.

Referenced by isHidden(), and RexxMethod1().

◆ exists() [2/2]

static bool SysFileSystem::exists ( const char *  name)
static

◆ extractDirectory() [1/2]

RexxString * SysFileSystem::extractDirectory ( RexxString file)
static

Extract directory information from a file name.

Parameters
fileThe input file name. If this represents a real source file, this will be fully resolved.
Returns
The directory portion of the file name. If the file name does not include a directory portion, then OREF_NULL is returned.

Definition at line 247 of file unix/SysFileSystem.cpp.

References RexxString::getBLength(), RexxString::getStringData(), new_string(), and OREF_NULL.

Referenced by RexxSource::extractNameInformation().

◆ extractDirectory() [2/2]

static RexxString* SysFileSystem::extractDirectory ( RexxString file)
static

◆ extractExtension() [1/2]

RexxString * SysFileSystem::extractExtension ( RexxString file)
static

Extract extension information from a file name.

Parameters
fileThe input file name. If this represents a real source file, this will be fully resolved.
Returns
The extension portion of the file name. If the file name does not include an extension portion, then OREF_NULL is returned.

Definition at line 279 of file unix/SysFileSystem.cpp.

References RexxString::getBLength(), RexxString::getStringData(), new_string(), and OREF_NULL.

Referenced by RexxSource::extractNameInformation().

◆ extractExtension() [2/2]

static RexxString* SysFileSystem::extractExtension ( RexxString file)
static

◆ extractFile() [1/2]

RexxString * SysFileSystem::extractFile ( RexxString file)
static

Extract file information from a file name.

Parameters
fileThe input file name. If this represents a real source file, this will be fully resolved.
Returns
The file portion of the file name. If the file name does not include a directory portion, then the entire string is returned

Definition at line 315 of file unix/SysFileSystem.cpp.

References RexxString::getBLength(), RexxString::getStringData(), and new_string().

Referenced by RexxSource::extractNameInformation().

◆ extractFile() [2/2]

static RexxString* SysFileSystem::extractFile ( RexxString file)
static

◆ fileExists() [1/2]

bool SysFileSystem::fileExists ( const char *  name)
static

Test if a given file exists.

Parameters
fnameThe target file name.
Returns
true if the file exists, false otherwise.

Check to see if a file with a given name exists.

Parameters
nameThe name to check.
Returns
True if the file exists, false otherwise.

Definition at line 221 of file unix/SysFileSystem.cpp.

Referenced by searchFileName(), StreamInfo::streamExists(), and StreamInfo::streamOpen().

◆ fileExists() [2/2]

static bool SysFileSystem::fileExists ( const char *  name)
static

◆ findFirstFile()

bool SysFileSystem::findFirstFile ( const char *  name)
static

Perform a "find first" operation for a file.

Parameters
namethe target name (may include wildcard characters)
Returns
true if a file was located, false if not.

Definition at line 186 of file windows/SysFileSystem.cpp.

◆ getFileLength() [1/2]

int64_t SysFileSystem::getFileLength ( const char *  name)
static

Retrieve the size of a file.

Parameters
nameThe name of the target file.
Returns
the 64-bit file size.

Definition at line 891 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ getFileLength() [2/2]

static int64_t SysFileSystem::getFileLength ( const char *  name)
static

◆ getLastModifiedDate() [1/2]

int64_t SysFileSystem::getLastModifiedDate ( const char *  name)
static

Get the last modified file date as a file time value.

Parameters
nameThe target name.
Returns
the file time value for the modified date, or -1 for any errors. The time is returned in ticks units

Get the last modified file date as a file time value.

Parameters
nameThe target name.
Returns
the file time value for the modified date, or -1 for any errors.

Definition at line 871 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ getLastModifiedDate() [2/2]

static int64_t SysFileSystem::getLastModifiedDate ( const char *  name)
static

◆ getLongName()

void SysFileSystem::getLongName ( char *  fullName,
size_t  size 
)
static

Get the actual name value of a located file, in the exact case used on the harddrive.

Parameters
fullNameThe buffer used for the name.
sizeThe size of the buffer.

Definition at line 531 of file windows/SysFileSystem.cpp.

Referenced by searchPath().

◆ getPathSeparator() [1/2]

const char * SysFileSystem::getPathSeparator ( )
static

Return the separator used for separating search path elements

Returns
The ASCII-Z version of the path separator.

Definition at line 1043 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod0().

◆ getPathSeparator() [2/2]

static const char* SysFileSystem::getPathSeparator ( )
static

◆ getRoots() [1/2]

int SysFileSystem::getRoots ( char *  roots)
static

Retrieve the file system root elements. On Windows, each of the drives is a root element.

Returns
The number of roots located.

Definition at line 1019 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod0().

◆ getRoots() [2/2]

static int SysFileSystem::getRoots ( char *  roots)
static

◆ getSeparator() [1/2]

const char * SysFileSystem::getSeparator ( )
static

Return the separator used for separating path names.

Returns
The ASCII-Z version of the path separator.

Definition at line 1032 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod0().

◆ getSeparator() [2/2]

static const char* SysFileSystem::getSeparator ( )
static

◆ getTempFileName() [1/2]

const char * SysFileSystem::getTempFileName ( )
static

Generate a temporary file name.

Returns
The string name of the temporary file.

Definition at line 171 of file unix/SysFileSystem.cpp.

Referenced by RexxMemory::checkSetOref(), and RexxMemory::orphanCheckMark().

◆ getTempFileName() [2/2]

static const char* SysFileSystem::getTempFileName ( )
static

◆ hasDirectory() [1/2]

bool SysFileSystem::hasDirectory ( const char *  name)
static

Test if a filename has a directory portion

Parameters
nameThe name to check.
Returns
true if a directory was found on the file, false if there is no directory.

Definition at line 378 of file unix/SysFileSystem.cpp.

Referenced by primitiveSearchName().

◆ hasDirectory() [2/2]

static bool SysFileSystem::hasDirectory ( const char *  name)
static

◆ hasExtension() [1/2]

bool SysFileSystem::hasExtension ( const char *  name)
static

Test if a filename has an extension.

Parameters
nameThe name to check.
Returns
true if an extension was found on the file, false if there is no extension.

Definition at line 345 of file unix/SysFileSystem.cpp.

Referenced by SysInterpreterInstance::resolveProgramName().

◆ hasExtension() [2/2]

static bool SysFileSystem::hasExtension ( const char *  name)
static

◆ isCaseSensitive() [1/2]

bool SysFileSystem::isCaseSensitive ( )
static

indicate whether the file system is case sensitive.

Returns
For Unix systems, always returns true.

indicate whether the file system is case sensitive.

Returns
For Windows, always returns false.

Definition at line 1007 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod0().

◆ isCaseSensitive() [2/2]

static bool SysFileSystem::isCaseSensitive ( )
static

◆ isDirectory() [1/2]

bool SysFileSystem::isDirectory ( const char *  name)
static

Test if a given file name is for a directory.

Parameters
nameThe target name.
Returns
true if the file is a directory, false for any other type of entity.

Definition at line 793 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ isDirectory() [2/2]

static bool SysFileSystem::isDirectory ( const char *  name)
static

◆ isFile() [1/2]

bool SysFileSystem::isFile ( const char *  name)
static

Test if a give file name is for a real file (not a directory).

Parameters
nameThe target file name.
Returns
true if the file is a real file, false if some other filesystem entity.

Definition at line 838 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ isFile() [2/2]

static bool SysFileSystem::isFile ( const char *  name)
static

◆ isHidden() [1/2]

bool SysFileSystem::isHidden ( const char *  name)
static

Test if a given file or directory is hidden.

Parameters
nameThe target name.
Returns
true if the file or directory is hidden, false otherwise.

Definition at line 936 of file unix/SysFileSystem.cpp.

References exists().

Referenced by RexxMethod1().

◆ isHidden() [2/2]

static bool SysFileSystem::isHidden ( const char *  name)
static

◆ isReadOnly() [1/2]

bool SysFileSystem::isReadOnly ( const char *  name)
static

Test is a file is read only.

Parameters
nameThe target file name.
Returns
true if the file is marked as read-only.

Definition at line 809 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ isReadOnly() [2/2]

static bool SysFileSystem::isReadOnly ( const char *  name)
static

◆ isWriteOnly() [1/2]

bool SysFileSystem::isWriteOnly ( const char *  name)
static

Test if a file is marked as write-only.

Parameters
nameThe target file name.
Returns
true if the file is only writeable. false if read operations are permitted.

Definition at line 823 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ isWriteOnly() [2/2]

static bool SysFileSystem::isWriteOnly ( const char *  name)
static

◆ makeDirectory() [1/2]

bool SysFileSystem::makeDirectory ( const char *  name)
static

Create a directory in the file system.

Parameters
nameThe target name.
Returns
The success/failure flag.

Definition at line 909 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ makeDirectory() [2/2]

static bool SysFileSystem::makeDirectory ( const char *  name)
static

◆ moveFile() [1/2]

bool SysFileSystem::moveFile ( const char *  oldName,
const char *  newName 
)
static

Move (rename) a file.

Parameters
oldNameThe name of an existing file.
newNameThe new file name.
Returns
A success/failure flag.

Definition at line 923 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod2().

◆ moveFile() [2/2]

static bool SysFileSystem::moveFile ( const char *  oldName,
const char *  newName 
)
static

◆ normalizePathName()

bool SysFileSystem::normalizePathName ( const char *  name,
char *  resolved 
)
static

Normalize an absolute Unix path name. Removes duplicate and trailing slashes, resolves and removes ./ or ../ This works for any path name, whether the resovled name exists or not.

Parameters
nameThe path name to normalize.
resolvedOn success the normalized name is returned here.
Returns
True on success, otherwise false.

@assumes Name is null-terminated and that resolved is an adequate buffer.

Definition at line 676 of file unix/SysFileSystem.cpp.

Referenced by canonicalizeName().

◆ primitiveSearchName() [1/2]

bool SysFileSystem::primitiveSearchName ( const char *  name,
const char *  path,
const char *  extension,
char *  resolvedName 
)
static

Do a search for a single variation of a filename.

Parameters
nameThe name to search for.
directoryA specific directory to look in first (can be NULL).
extensionA potential extension to add to the file name (can be NULL).
resolvedNameThe buffer used to return the resolved file name.
Returns
true if the file was located. A true returns indicates the resolved file name has been placed in the provided buffer.

Do a search for a single variation of a filename.

NOTE: This version does not do anything with the kernel lock, so it is callable before the first activity is set up.

Parameters
nameThe name to search for.
path
extensionA potential extension to add to the file name (can be NULL).
resolvedNameThe buffer used to return the resolved file name.
Returns
true if the file was located. A true returns indicates the resolved file name has been placed in the provided buffer.

Definition at line 418 of file unix/SysFileSystem.cpp.

References checkCurrentFile(), hasDirectory(), searchPath(), and Utilities::strlower().

Referenced by SystemInterpreter::loadImage(), and searchName().

◆ primitiveSearchName() [2/2]

static bool SysFileSystem::primitiveSearchName ( const char *  name,
const char *  path,
const char *  extension,
char *  resolvedName 
)
static

◆ qualifyStreamName() [1/2]

void SysFileSystem::qualifyStreamName ( const char *  unqualifiedName,
char *  qualifiedName,
size_t  bufferSize 
)
static

Generate a fully qualified stream name.

Parameters
unqualifiedNameThe starting name.
qualifiedNameThe fully expanded and canonicalized file name.
bufferSize

Definition at line 177 of file unix/SysFileSystem.cpp.

References canonicalizeName(), and MaximumFileNameBuffer.

Referenced by BUILTIN(), SystemInterpreter::qualifyFileSystemName(), StreamInfo::resolveStreamName(), and RexxMethod1().

◆ qualifyStreamName() [2/2]

static void SysFileSystem::qualifyStreamName ( const char *  unqualifiedName,
char *  qualifiedName,
size_t  bufferSize 
)
static

◆ searchFileName() [1/2]

bool SysFileSystem::searchFileName ( const char *  name,
char *  fullName 
)
static

Definition at line 77 of file unix/SysFileSystem.cpp.

References canonicalizeName(), fileExists(), and MaximumFileNameBuffer.

◆ searchFileName() [2/2]

static bool SysFileSystem::searchFileName ( const char *  name,
char *  fullName 
)
static

◆ searchName() [1/2]

bool SysFileSystem::searchName ( const char *  name,
const char *  path,
const char *  extension,
char *  resolvedName 
)
static

Do a search for a single variation of a filename.

Parameters
nameThe name to search for.
directoryA specific directory to look in first (can be NULL).
extensionA potential extension to add to the file name (can be NULL).
resolvedNameThe buffer used to return the resolved file name.
Returns
true if the file was located. A true returns indicates the resolved file name has been placed in the provided buffer.

Definition at line 399 of file unix/SysFileSystem.cpp.

References primitiveSearchName().

Referenced by SysInterpreterInstance::resolveProgramName().

◆ searchName() [2/2]

static bool SysFileSystem::searchName ( const char *  name,
const char *  path,
const char *  extension,
char *  resolvedName 
)
static

◆ searchPath() [1/2]

bool SysFileSystem::searchPath ( const char *  name,
const char *  path,
char *  resolvedName 
)
static

Do a path search for a file.

Parameters
nameThe name to search for.
pathThe search path to use.
resolvedNameA buffer used for returning the resolved name.
Returns
Returns true if the file was located. If true, the resolvedName buffer will contain the returned name.

Definition at line 520 of file unix/SysFileSystem.cpp.

References canonicalizeName().

Referenced by primitiveSearchName().

◆ searchPath() [2/2]

bool SysFileSystem::searchPath ( const char *  name,
const char *  path,
const char *  extension,
char *  resolvedName 
)
static

Do a path search for a file.

Parameters
nameThe name to search for.
pathThe search path to use.
extensionAny extension that should be added to the search (can be NULL).
resolvedNameA buffer used for returning the resolved name.
Returns
Returns true if the file was located. If true, the resolvedName buffer will contain the returned name.

Definition at line 502 of file windows/SysFileSystem.cpp.

References getLongName(), and SearchPath().

◆ setFileReadOnly() [1/2]

bool SysFileSystem::setFileReadOnly ( const char *  name)
static

Set the read-only attribute on a file or directory.

Parameters
nameThe target name.
Returns
true if the attribute was set, false otherwise.

Definition at line 988 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod1().

◆ setFileReadOnly() [2/2]

static bool SysFileSystem::setFileReadOnly ( const char *  name)
static

◆ setLastModifiedDate() [1/2]

bool SysFileSystem::setLastModifiedDate ( const char *  name,
int64_t  time 
)
static

Set the last modified date for a file.

Parameters
nameThe target name.
timeThe new file time (in ticks).
Returns
true if the filedate was set correctly, false otherwise.

Set the last modified date for a file.

Parameters
nameThe target name.
timeThe new file time.
Returns
true if the filedate was set correctly, false otherwise.

Open the path ensuring GENERIC_WRITE and FILE_FLAG_BACKUP_SEMANTICS if it's a directory. The directory modification is only supported on some platforms (NT, Windows2000).

Definition at line 965 of file unix/SysFileSystem.cpp.

Referenced by RexxMethod2().

◆ setLastModifiedDate() [2/2]

static bool SysFileSystem::setLastModifiedDate ( const char *  name,
int64_t  time 
)
static

Member Data Documentation

◆ EOF_Marker

static const char SysFileSystem::EOF_Marker = 0x1A
static

Definition at line 85 of file unix/SysFileSystem.hpp.

◆ EOL_Marker

static const char * SysFileSystem::EOL_Marker = "\n"
static

Definition at line 86 of file unix/SysFileSystem.hpp.

◆ PathDelimiter

static const char SysFileSystem::PathDelimiter = '/'
static

Definition at line 87 of file unix/SysFileSystem.hpp.

◆ stderrHandle

int SysFileSystem::stderrHandle = 2
static

Definition at line 65 of file windows/SysFileSystem.hpp.

◆ stdinHandle

int SysFileSystem::stdinHandle = 0
static

Definition at line 63 of file windows/SysFileSystem.hpp.

◆ stdoutHandle

int SysFileSystem::stdoutHandle = 1
static

Definition at line 64 of file windows/SysFileSystem.hpp.


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