projects
/
feisty_meow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'dev' of feistymeow.org:feisty_meow into dev
[feisty_meow.git]
/
nucleus
/
library
/
filesystem
/
filename.cpp
diff --git
a/nucleus/library/filesystem/filename.cpp
b/nucleus/library/filesystem/filename.cpp
index a77035baeabb3f795ad586b79ba471da3c62e0f9..ed7b914aa518d2d1b0c5fb017da2414456d94e22 100644
(file)
--- a/
nucleus/library/filesystem/filename.cpp
+++ b/
nucleus/library/filesystem/filename.cpp
@@
-24,10
+24,9
@@
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
-#if
def __UNIX__
+#if
defined(__UNIX__) || defined(__GNU_WINDOWS__)
#include <unistd.h>
#include <unistd.h>
-#endif
-#ifdef __WIN32__
+#else
#include <io.h>
#endif
#include <io.h>
#endif
@@
-100,6
+99,12
@@
bool filename::good() const { return exists(); }
bool filename::unlink() const { return ::unlink(observe()) == 0; }
bool filename::unlink() const { return ::unlink(observe()) == 0; }
+void filename::reset(const astring &name) {
+ *this = name;
+ _had_directory = true; // until we know better.
+ canonicalize();
+}
+
astring filename::null_device()
{
#ifdef __WIN32__
astring filename::null_device()
{
#ifdef __WIN32__
@@
-185,13
+190,22
@@
void filename::canonicalize()
// on windows, we want to translate away from any cygwin or msys format into a more palatable
// version that the rest of windows understands.
// first, cygwin...
// on windows, we want to translate away from any cygwin or msys format into a more palatable
// version that the rest of windows understands.
// first, cygwin...
- const astring CYGDRIVE_PATH = astring(astring(DEFAULT_SEPARATOR, 1) + "cygdrive"
- + astring(DEFAULT_SEPARATOR, 1));
+//hmmm: make these into statics!
+ const astring CYGDRIVE_SENTINEL = "cygdrive";
+ const astring CYGDRIVE_PATH = astring(astring(DEFAULT_SEPARATOR, 1)
+ + CYGDRIVE_SENTINEL + astring(DEFAULT_SEPARATOR, 1));
+
// must be at least as long as the string we're looking for, plus a drive letter afterwards.
// must be at least as long as the string we're looking for, plus a drive letter afterwards.
- if ( (length() > CYGDRIVE_PATH.length() + 1) && begins(CYGDRIVE_PATH) ) {
+ if ( (length() >= CYGDRIVE_PATH.length() + 1)
+ && separator(get(0))
+ && separator(get(CYGDRIVE_PATH.length() - 1))
+ && compare(CYGDRIVE_SENTINEL, 1,
+ 0, CYGDRIVE_SENTINEL.length(), true) ) {
zap(0, CYGDRIVE_PATH.length() - 1); // whack the cygdrive portion plus two slashes.
insert(1, ":"); // add a colon after the imputed drive letter.
zap(0, CYGDRIVE_PATH.length() - 1); // whack the cygdrive portion plus two slashes.
insert(1, ":"); // add a colon after the imputed drive letter.
-LOG(astring("turned cygdrive string into: ") + *this);
+//LOG(astring("turned cygdrive path string into: ") + *this);
+ } else {
+//LOG(astring("path didn't match so left as: ") + *this);
}
// now we convert msys...
if ( (length() >= 2) && (get(0) == DEFAULT_SEPARATOR)
}
// now we convert msys...
if ( (length() >= 2) && (get(0) == DEFAULT_SEPARATOR)
@@
-210,7
+224,7
@@
LOG(astring("turned cygdrive string into: ") + *this);
// then only on the near defunct windows platform.
zap(0, 0); // take off initial slash.
insert(1, ":"); // add the obligatory colon.
// then only on the near defunct windows platform.
zap(0, 0); // take off initial slash.
insert(1, ":"); // add the obligatory colon.
-LOG(astring("turned msys string into: ") + *this);
+
//
LOG(astring("turned msys string into: ") + *this);
}
}
#endif
}
}
#endif
@@
-309,10
+323,15
@@
bool filename::is_normal() const
status_info fill;
if (!get_info(&fill))
return false;
status_info fill;
if (!get_info(&fill))
return false;
+#if defined(__WIN32__) || defined(__VMS__)
+//hmmm: is there a corresponding set of functions for windows, where applicable?
+ bool weird = false;
+#else
bool weird = S_ISCHR(fill.st_mode)
|| S_ISBLK(fill.st_mode)
|| S_ISFIFO(fill.st_mode)
|| S_ISSOCK(fill.st_mode);
bool weird = S_ISCHR(fill.st_mode)
|| S_ISBLK(fill.st_mode)
|| S_ISFIFO(fill.st_mode)
|| S_ISSOCK(fill.st_mode);
+#endif
return !weird;
}
return !weird;
}
@@
-372,11
+391,10
@@
bool filename::exists() const
{
if (is_directory())
return true;
{
if (is_directory())
return true;
+ // if the file name is empty, that cannot exist.
if (!length())
return false;
return is_readable();
if (!length())
return false;
return is_readable();
-/// byte_filer opened(observe(), "rb");
-/// return opened.good();
}
bool filename::legal_character(char to_check)
}
bool filename::legal_character(char to_check)