mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-21 12:25:30 +00:00
* BugFix: Corrections to the Unix file IO to allow for compilation on ARM Unix devics.
This commit is contained in:
parent
ac3126765f
commit
dd03af5041
4 changed files with 94 additions and 84 deletions
|
|
@ -179,82 +179,6 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
|||
return sgPrefDir;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// munge the case of the specified pathName. This means try to find the actual
|
||||
// filename in with case-insensitive matching on the specified pathName, and
|
||||
// store the actual found name.
|
||||
bool ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize, bool requiredAbsolute)
|
||||
{
|
||||
char tempBuf[MaxPath];
|
||||
dStrncpy(tempBuf, pathName, pathNameSize);
|
||||
|
||||
// Check if we're an absolute path
|
||||
if (pathName[0] != '/')
|
||||
{
|
||||
AssertFatal(!requiredAbsolute, "PATH must be absolute");
|
||||
return false;
|
||||
}
|
||||
|
||||
struct stat filestat;
|
||||
const int MaxPathEl = 200;
|
||||
char *currChar = pathName;
|
||||
char testPath[MaxPath];
|
||||
char pathEl[MaxPathEl];
|
||||
bool done = false;
|
||||
bool foundMatch = false;
|
||||
|
||||
dStrncpy(tempBuf, "/", MaxPath);
|
||||
currChar++;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
char* termChar = dStrchr(currChar, '/');
|
||||
if (termChar == NULL)
|
||||
termChar = dStrchr(currChar, '\0');
|
||||
AssertFatal(termChar, "Can't find / or NULL terminator");
|
||||
|
||||
S32 pathElLen = (termChar - currChar);
|
||||
dStrncpy(pathEl, currChar, pathElLen);
|
||||
pathEl[pathElLen] = '\0';
|
||||
dStrncpy(testPath, tempBuf, MaxPath);
|
||||
dStrcat(testPath, pathEl, MaxPath);
|
||||
if (stat(testPath, &filestat) != -1)
|
||||
{
|
||||
dStrncpy(tempBuf, testPath, MaxPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
DIR *dir = opendir(tempBuf);
|
||||
struct dirent* ent;
|
||||
while (dir != NULL && (ent = readdir(dir)) != NULL)
|
||||
{
|
||||
if (dStricmp(pathEl, ent->d_name) == 0)
|
||||
{
|
||||
foundMatch = true;
|
||||
dStrcat(tempBuf, ent->d_name, MaxPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMatch)
|
||||
dStrncpy(tempBuf, testPath, MaxPath);
|
||||
if (dir)
|
||||
closedir(dir);
|
||||
}
|
||||
if (*termChar == '/')
|
||||
{
|
||||
dStrcat(tempBuf, "/", MaxPath);
|
||||
termChar++;
|
||||
currChar = termChar;
|
||||
}
|
||||
else
|
||||
done = true;
|
||||
}
|
||||
|
||||
dStrncpy(pathName, tempBuf, pathNameSize);
|
||||
return foundMatch;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns true if the pathname exists, false otherwise. If isFile is true,
|
||||
// the pathname is assumed to be a file path, and only the directory part
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platformX86UNIX/platformX86UNIX.h"
|
||||
#include "core/volume.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
#include <dirent.h>
|
||||
|
||||
int x86UNIXOpen(const char *path, int oflag)
|
||||
{
|
||||
return open(path, oflag, 0666);
|
||||
}
|
||||
|
||||
int x86UNIXClose(int fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
ssize_t x86UNIXRead(int fd, void *buf, size_t nbytes)
|
||||
{
|
||||
return read(fd, buf, nbytes);
|
||||
}
|
||||
|
||||
ssize_t x86UNIXWrite(int fd, const void *buf, size_t nbytes)
|
||||
{
|
||||
return write(fd, buf, nbytes);
|
||||
}
|
||||
|
||||
bool Torque::FS::VerifyWriteAccess(const Torque::Path &path)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue