mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Remove unused ddio_CleanPath()
This commit is contained in:
parent
cab252f66c
commit
8940a5ae38
@ -374,12 +374,6 @@ void ddio_MakePath(char *newPath, const char *absolutePathHeader, const char *su
|
||||
void ddio_DoForeachFile(const std::filesystem::path &search_path, const std::regex ®ex,
|
||||
const std::function<void(std::filesystem::path)> &func);
|
||||
|
||||
// given a path, it cleans it up (if the path is c:\windows\..\dos it would make it c:\dos)
|
||||
// srcPath is the original path
|
||||
// dest is the finished cleaned path.
|
||||
// dest should be at least _MAX_PATH in size
|
||||
void ddio_CleanPath(char *dest, const char *srcPath);
|
||||
|
||||
// Generates a temporary filename based on the prefix, and basedir
|
||||
// Parameters:
|
||||
// basedir - directory to put the files
|
||||
|
120
ddio/lnxfile.cpp
120
ddio/lnxfile.cpp
@ -266,126 +266,6 @@ int ddio_GetFileSysRoots(char **roots, int max_roots) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// given a path, it cleans it up (if the path is /usr/lib/../src it would make it /usr/src)
|
||||
// srcPath is the original path
|
||||
// dest is the finished cleaned path.
|
||||
// dest should be at least _MAX_PATH in size
|
||||
void ddio_CleanPath(char *dest, const char *srcPath) {
|
||||
// NOTE: we may want to use getcwd() here if we don't want symbolic links
|
||||
// but I think we do
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
strcpy(dest, srcPath);
|
||||
|
||||
// break the path into directories
|
||||
char **directories;
|
||||
int dirs;
|
||||
int path_length;
|
||||
|
||||
// make sure the path ends with a / for sanity
|
||||
path_length = strlen(dest);
|
||||
|
||||
if (dest[path_length - 1] != '/') {
|
||||
dest[path_length] = '/';
|
||||
dest[path_length + 1] = '\0';
|
||||
path_length++;
|
||||
}
|
||||
|
||||
// now divide the full path into separate NULL terminated strings,counting the number
|
||||
// of directories in the process
|
||||
dirs = 0;
|
||||
char *strptr;
|
||||
if (dest[0] == '/')
|
||||
strptr = dest + 1; // skip first / of root dir
|
||||
else
|
||||
strptr = dest;
|
||||
|
||||
while (*strptr != '\0') {
|
||||
if (*strptr == '/') {
|
||||
*strptr = '\0';
|
||||
dirs++;
|
||||
}
|
||||
strptr++;
|
||||
}
|
||||
|
||||
// check to make sure we have a directory, if we don't then return the original path given
|
||||
if (dirs == 0) {
|
||||
strcpy(dest, srcPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// allocate the memory needed for the separate strings of each directory
|
||||
directories = mem_rmalloc<char *>(dirs);
|
||||
if (!directories) {
|
||||
strcpy(dest, srcPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// now get all the directories, and place into the individual strings
|
||||
strptr = dest;
|
||||
int count = 0;
|
||||
while (count < dirs) {
|
||||
directories[count] = mem_strdup(strptr);
|
||||
strptr += strlen(strptr) + 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
// now the fun part, figure out the correct order of the directories
|
||||
int *dir_order;
|
||||
|
||||
dir_order = mem_rmalloc<int>(dirs);
|
||||
if (!dir_order) {
|
||||
strcpy(dest, srcPath);
|
||||
return;
|
||||
}
|
||||
|
||||
for (count = 0; count < dirs; count++)
|
||||
dir_order[count] = -1; // a -1 means the end of the sequence
|
||||
|
||||
// now build the order based on the indicies
|
||||
int curr_index = 0;
|
||||
for (count = 0; count < dirs; count++) {
|
||||
|
||||
if (!stricmp(directories[count], "..")) {
|
||||
// we have to back up a directory
|
||||
curr_index--; // back up
|
||||
if (curr_index < 0)
|
||||
curr_index = 0; // can't go further than root
|
||||
dir_order[curr_index] = -1; // invalidate current slot
|
||||
} else if (stricmp(directories[count], ".")) {
|
||||
// we have a normal directory, add its index
|
||||
dir_order[curr_index] = count;
|
||||
curr_index++;
|
||||
}
|
||||
}
|
||||
|
||||
// now rebuild the correct path for use, when we hit -1, we're done
|
||||
dest[0] = '\0';
|
||||
for (count = 0; count < dirs; count++) {
|
||||
if (dir_order[count] == -1)
|
||||
break;
|
||||
else {
|
||||
strcat(dest, directories[dir_order[count]]);
|
||||
strcat(dest, "/");
|
||||
}
|
||||
}
|
||||
|
||||
// now remove trailing / char
|
||||
path_length = strlen(dest);
|
||||
if ((path_length > 0) && (dest[path_length - 1] == '/'))
|
||||
dest[path_length - 1] = '\0';
|
||||
|
||||
// free up all the allocated memory and we're done
|
||||
for (count = 0; count < dirs; count++) {
|
||||
if (directories[count])
|
||||
mem_free(directories[count]);
|
||||
}
|
||||
if (directories)
|
||||
mem_free(directories);
|
||||
if (dir_order)
|
||||
mem_free(dir_order);
|
||||
}
|
||||
|
||||
// Generates a temporary filename based on the prefix, and basedir
|
||||
// Parameters:
|
||||
// basedir - directory to put the files
|
||||
|
111
ddio/winfile.cpp
111
ddio/winfile.cpp
@ -354,117 +354,6 @@ std::vector<std::filesystem::path> ddio_GetSysRoots() {
|
||||
return result;
|
||||
};
|
||||
|
||||
// given a path, it cleans it up (if the path is c:\windows\..\dos it would make it c:\dos)
|
||||
// srcPath is the original path
|
||||
// dest is the finished cleaned path.
|
||||
// dest should be at least _MAX_PATH in size
|
||||
void ddio_CleanPath(char *dest, const char *srcPath) {
|
||||
strcpy(dest, srcPath);
|
||||
|
||||
// break the path into directories
|
||||
char **directories;
|
||||
int dirs;
|
||||
int path_length;
|
||||
|
||||
// make sure the path ends with a \ for sanity
|
||||
path_length = strlen(dest);
|
||||
|
||||
if (dest[path_length - 1] != '\\') {
|
||||
dest[path_length] = '\\';
|
||||
dest[path_length + 1] = '\0';
|
||||
path_length++;
|
||||
}
|
||||
|
||||
// now divide the full path into separate NULL terminated strings,counting the number
|
||||
// of directories in the process
|
||||
dirs = 0;
|
||||
char *strptr = dest;
|
||||
while (*strptr != '\0') {
|
||||
if (*strptr == '\\') {
|
||||
*strptr = '\0';
|
||||
dirs++;
|
||||
}
|
||||
strptr++;
|
||||
}
|
||||
|
||||
// check to make sure we have a directory, if we don't then return the original path given
|
||||
if (dirs == 0) {
|
||||
strcpy(dest, srcPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// allocate the memory needed for the separate strings of each directory
|
||||
directories = mem_rmalloc<char *>(dirs);
|
||||
if (!directories) {
|
||||
strcpy(dest, srcPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// now get all the directories, and place into the individual strings
|
||||
strptr = dest;
|
||||
int count = 0;
|
||||
while (count < dirs) {
|
||||
directories[count] = mem_strdup(strptr);
|
||||
strptr += strlen(strptr) + 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
// now the fun part, figure out the correct order of the directories
|
||||
int *dir_order;
|
||||
|
||||
dir_order = mem_rmalloc<int>(dirs);
|
||||
if (!dir_order) {
|
||||
strcpy(dest, srcPath);
|
||||
return;
|
||||
}
|
||||
|
||||
for (count = 0; count < dirs; count++)
|
||||
dir_order[count] = -1; // a -1 means the end of the sequence
|
||||
|
||||
// now build the order based on the indicies
|
||||
int curr_index = 0;
|
||||
for (count = 0; count < dirs; count++) {
|
||||
|
||||
if (!stricmp(directories[count], "..")) {
|
||||
// we have to back up a directory
|
||||
curr_index--; // back up
|
||||
if (curr_index < 0)
|
||||
curr_index = 0; // can't go further than root
|
||||
dir_order[curr_index] = -1; // invalidate current slot
|
||||
} else if (stricmp(directories[count], ".")) {
|
||||
// we have a normal directory, add its index
|
||||
dir_order[curr_index] = count;
|
||||
curr_index++;
|
||||
}
|
||||
}
|
||||
|
||||
// now rebuild the correct path for use, when we hit -1, we're done
|
||||
dest[0] = '\0';
|
||||
for (count = 0; count < dirs; count++) {
|
||||
if (dir_order[count] == -1)
|
||||
break;
|
||||
else {
|
||||
strcat(dest, directories[dir_order[count]]);
|
||||
strcat(dest, "\\");
|
||||
}
|
||||
}
|
||||
|
||||
// now remove trailing \ char
|
||||
path_length = strlen(dest);
|
||||
if ((path_length > 0) && (dest[path_length - 1] == '\\'))
|
||||
dest[path_length - 1] = '\0';
|
||||
|
||||
// free up all the allocated memory and we're done
|
||||
for (count = 0; count < dirs; count++) {
|
||||
if (directories[count])
|
||||
mem_free(directories[count]);
|
||||
}
|
||||
if (directories)
|
||||
mem_free(directories);
|
||||
if (dir_order)
|
||||
mem_free(dir_order);
|
||||
}
|
||||
|
||||
bool ddio_CheckProcess(int pid) {
|
||||
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
|
||||
if (proc) {
|
||||
|
@ -287,7 +287,6 @@ inline void CFileList::setPath(CString path) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
// ddio_CleanPath(buffer,temp.GetBuffer(0));
|
||||
strcpy(buffer, temp.GetBuffer(0));
|
||||
|
||||
m_csPath = buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user