move redir handling

This commit is contained in:
Glenn Maynard
2003-01-01 22:02:41 +00:00
parent 83062aee55
commit d848550137
3 changed files with 34 additions and 18 deletions
+22
View File
@@ -19,6 +19,7 @@ unsigned long randseed = time(NULL);
#include <math.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fstream>
int power_of_two(int input)
{
@@ -746,3 +747,24 @@ void TrimRight(CString &str, const char *s)
* if n == 0, the whole string is erased. */
str.erase(str.begin()+n, str.end());
}
/* path is a .redir pathname. Read it and return the real one. */
CString DerefRedir(const CString &path)
{
CString sDir, sFName, sExt;
splitrelpath( path, sDir, sFName, sExt );
if(sExt != "redir") return path;
CString sNewFileName;
{
ifstream file(path);
getline(file, sNewFileName);
}
/* Empty is invalid. */
if(sNewFileName == "")
return "";
return sDir+sNewFileName;
}