VFS: Only use Windows paths on Windows, cleanup.

This commit is contained in:
Unknown W. Brackets 2016-02-29 00:32:31 -08:00
parent 5451334b38
commit ee27d838dd

View file

@ -332,10 +332,18 @@ void VFSShutdown() {
num_entries = 0; num_entries = 0;
} }
static bool IsLocalPath(const char *path) {
bool isUnixLocal = path[0] == '/';
#ifdef _WIN32
bool isWindowsLocal = isalpha(path[0]) && path[1] == ':';
#else
bool isWindowsLocal = false;
#endif
return isUnixLocal || isWindowsLocal;
}
uint8_t *VFSReadFile(const char *filename, size_t *size) { uint8_t *VFSReadFile(const char *filename, size_t *size) {
bool isUnixLocal = filename[0] == '/'; if (IsLocalPath(filename)) {
bool isWindowsLocal = isalpha(filename[0]) && filename[1] == ':' && (filename[2] == '/' || filename[2] == '\\');
if (isUnixLocal || isWindowsLocal) {
// Local path, not VFS. // Local path, not VFS.
ILOG("Not a VFS path: %s . Reading local file.", filename); ILOG("Not a VFS path: %s . Reading local file.", filename);
return ReadLocalFile(filename, size); return ReadLocalFile(filename, size);
@ -364,11 +372,7 @@ uint8_t *VFSReadFile(const char *filename, size_t *size) {
} }
bool VFSGetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter) { bool VFSGetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter) {
#ifdef _WIN32 if (IsLocalPath(path)) {
if (path[1] == ':') {
#else
if (path[0] == '/') {
#endif
// Local path, not VFS. // Local path, not VFS.
ILOG("Not a VFS path: %s . Reading local directory.", path); ILOG("Not a VFS path: %s . Reading local directory.", path);
getFilesInDir(path, listing, filter); getFilesInDir(path, listing, filter);
@ -395,11 +399,7 @@ bool VFSGetFileListing(const char *path, std::vector<FileInfo> *listing, const c
} }
bool VFSGetFileInfo(const char *path, FileInfo *info) { bool VFSGetFileInfo(const char *path, FileInfo *info) {
#ifdef _WIN32 if (IsLocalPath(path)) {
if (path[1] == ':') {
#else
if (path[0] == '/') {
#endif
// Local path, not VFS. // Local path, not VFS.
ILOG("Not a VFS path: %s . Getting local file info.", path); ILOG("Not a VFS path: %s . Getting local file info.", path);
return getFileInfo(path, info); return getFileInfo(path, info);