projects
/
feisty_meow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fiddled some dashes.
[feisty_meow.git]
/
nucleus
/
library
/
filesystem
/
filename.cpp
diff --git
a/nucleus/library/filesystem/filename.cpp
b/nucleus/library/filesystem/filename.cpp
index adca7e99dcee76d0d31b12f473c455897d594d95..81ca6f02f69d7abd04724e4877110f3e05ad4bdd 100644
(file)
--- a/
nucleus/library/filesystem/filename.cpp
+++ b/
nucleus/library/filesystem/filename.cpp
@@
-100,6
+100,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__
@@
-309,10
+315,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
+383,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)
@@
-425,11
+435,12
@@
bool filename::unpack(byte_array &packed_form)
return true;
}
return true;
}
-void filename::separate(string_array &pieces) const
+void filename::separate(
bool &rooted,
string_array &pieces) const
{
pieces.reset();
const astring &raw_form = raw();
astring accumulator; // holds the names we find.
{
pieces.reset();
const astring &raw_form = raw();
astring accumulator; // holds the names we find.
+ rooted = raw_form.length() && separator(raw_form[0]);
for (int i = 0; i < raw_form.length(); i++) {
if (separator(raw_form[i])) {
// this is a separator character, so eat it and add the accumulated
for (int i = 0; i < raw_form.length(); i++) {
if (separator(raw_form[i])) {
// this is a separator character, so eat it and add the accumulated
@@
-445,9
+456,10
@@
void filename::separate(string_array &pieces) const
if (accumulator.length()) pieces += accumulator;
}
if (accumulator.length()) pieces += accumulator;
}
-void filename::join(const string_array &pieces)
+void filename::join(
bool rooted,
const string_array &pieces)
{
astring constructed_name; // we'll make a filename here.
{
astring constructed_name; // we'll make a filename here.
+ if (rooted) constructed_name += DEFAULT_SEPARATOR;
for (int i = 0; i < pieces.length(); i++) {
constructed_name += pieces[i];
if (!i || (i != pieces.length() - 1))
for (int i = 0; i < pieces.length(); i++) {
constructed_name += pieces[i];
if (!i || (i != pieces.length() - 1))
@@
-459,8
+471,13
@@
void filename::join(const string_array &pieces)
bool filename::base_compare_prefix(const filename &to_compare,
string_array &first, string_array &second)
{
bool filename::base_compare_prefix(const filename &to_compare,
string_array &first, string_array &second)
{
- separate(first);
- to_compare.separate(second);
+ bool first_rooted;
+ separate(first_rooted, first);
+ bool second_rooted;
+ to_compare.separate(second_rooted, second);
+ if (first_rooted != second_rooted) {
+ return false;
+ }
// that case should never be allowed, since there are some bits missing
// in the name to be compared.
if (first.length() > second.length())
// that case should never be allowed, since there are some bits missing
// in the name to be compared.
if (first.length() > second.length())
@@
-509,8
+526,10
@@
bool filename::compare_prefix(const filename &to_compare)
bool filename::base_compare_suffix(const filename &to_compare,
string_array &first, string_array &second)
{
bool filename::base_compare_suffix(const filename &to_compare,
string_array &first, string_array &second)
{
- separate(first);
- to_compare.separate(second);
+ bool first_rooted;
+ separate(first_rooted, first);
+ bool second_rooted;
+ to_compare.separate(second_rooted, second);
// that case should never be allowed, since there are some bits missing
// in the name to be compared.
if (first.length() > second.length())
// that case should never be allowed, since there are some bits missing
// in the name to be compared.
if (first.length() > second.length())