Initial source commit
This commit is contained in:
commit
f1384c11ee
335 changed files with 52715 additions and 0 deletions
95
minorGems/io/file/win32/PathWin32.cpp
Normal file
95
minorGems/io/file/win32/PathWin32.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Modification History
|
||||
*
|
||||
* 2001-February-12 Jason Rohrer
|
||||
* Created.
|
||||
*
|
||||
* 2001-March-4 Jason Rohrer
|
||||
* Fixed delimeter constants.
|
||||
*
|
||||
* 2001-August-1 Jason Rohrer
|
||||
* Added missing length return value.
|
||||
*
|
||||
* 2003-June-2 Jason Rohrer
|
||||
* Added support for new path checking functions.
|
||||
*
|
||||
* 2010-May-14 Jason Rohrer
|
||||
* String parameters as const to fix warnings.
|
||||
*/
|
||||
|
||||
#include "minorGems/io/file/Path.h"
|
||||
#include "minorGems/util/stringUtils.h"
|
||||
|
||||
|
||||
/*
|
||||
* Windows-specific path implementation.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
char Path::getDelimeter() {
|
||||
return '\\';
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *Path::getAbsoluteRoot( int *outLength) {
|
||||
// C:\ is the only root we can generically return
|
||||
|
||||
char *returnString = new char[3];
|
||||
|
||||
returnString[0] = 'C';
|
||||
returnString[1] = ':';
|
||||
returnString[2] = '\\';
|
||||
|
||||
*outLength = 3;
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char Path::isAbsolute( const char *inPathString ) {
|
||||
// ignore first character, which will be drive letter
|
||||
if( inPathString[1] == ':' && inPathString[2] == '\\' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *Path::extractRoot( const char *inPathString ) {
|
||||
if( isAbsolute( inPathString ) ){
|
||||
// copy path, then trim to only three characters
|
||||
|
||||
char *pathCopy = stringDuplicate( inPathString );
|
||||
pathCopy[ 3 ] = '\0';
|
||||
|
||||
char *trimmedCopy = stringDuplicate( pathCopy );
|
||||
delete [] pathCopy;
|
||||
|
||||
return trimmedCopy;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
char Path::isRoot( const char *inPathString ) {
|
||||
// must be of form "c:\"
|
||||
if( strlen( inPathString ) == 3 &&
|
||||
inPathString[1] == ':' &&
|
||||
inPathString[2] == '\\' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue