projects
/
feisty_meow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
updated readme
[feisty_meow.git]
/
nucleus
/
library
/
filesystem
/
directory.cpp
diff --git
a/nucleus/library/filesystem/directory.cpp
b/nucleus/library/filesystem/directory.cpp
index 8e7789521e434281fb47837dcea7477efc403d1e..f1341e683f50f197122882ce781c2094fd8a2ddc 100644
(file)
--- a/
nucleus/library/filesystem/directory.cpp
+++ b/
nucleus/library/filesystem/directory.cpp
@@
-15,7
+15,6
@@
#include "directory.h"
#include "filename.h"
#include "directory.h"
#include "filename.h"
-#include <algorithms/shell_sort.h>
#include <application/windoze_helper.h>
#include <basis/astring.h>
#include <basis/contracts.h>
#include <application/windoze_helper.h>
#include <basis/astring.h>
#include <basis/contracts.h>
@@
-27,13
+26,15
@@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
-#ifdef __UNIX__
+
+#include "../algorithms/sorts.h"
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
#include <dirent.h>
#include <fnmatch.h>
#include <string.h>
#include <unistd.h>
#endif
#include <dirent.h>
#include <fnmatch.h>
#include <string.h>
#include <unistd.h>
#endif
-#ifdef _
_WIN32__
+#ifdef _
MSC_VER
#include <direct.h>
#endif
#include <direct.h>
#endif
@@
-101,7
+102,7
@@
astring directory::absolute_path(const astring &rel_path)
{
char abs_path[MAX_ABS_PATH + 1];
abs_path[0] = '\0';
{
char abs_path[MAX_ABS_PATH + 1];
abs_path[0] = '\0';
-#ifdef _
_WIN32__
+#ifdef _
MSC_VER
if (!_fullpath(abs_path, rel_path.s(), MAX_ABS_PATH)) return "";
return abs_path;
#else
if (!_fullpath(abs_path, rel_path.s(), MAX_ABS_PATH)) return "";
return abs_path;
#else
@@
-113,7
+114,7
@@
astring directory::absolute_path(const astring &rel_path)
astring directory::current()
{
astring to_return("."); // failure result.
astring directory::current()
{
astring to_return("."); // failure result.
-#ifdef _
_WIN32__
+#ifdef _
MSC_VER
flexichar buffer[MAX_ABS_PATH + 1] = { '\0' };
GetCurrentDirectory(MAX_ABS_PATH, buffer);
to_return = from_unicode_temp(buffer);
flexichar buffer[MAX_ABS_PATH + 1] = { '\0' };
GetCurrentDirectory(MAX_ABS_PATH, buffer);
to_return = from_unicode_temp(buffer);
@@
-151,7
+152,7
@@
bool directory::rescan()
_folders->reset();
astring cur_dir = ".";
astring par_dir = "..";
_folders->reset();
astring cur_dir = ".";
astring par_dir = "..";
-#ifdef _
_WIN32__
+#ifdef _
MSC_VER
// start reading the directory.
WIN32_FIND_DATA wfd;
astring real_path_spec = *_path + "/" + *_pattern;
// start reading the directory.
WIN32_FIND_DATA wfd;
astring real_path_spec = *_path + "/" + *_pattern;
@@
-194,8
+195,7
@@
bool directory::rescan()
}
} while (FindNextFile(search_handle, &wfd));
FindClose(search_handle);
}
} while (FindNextFile(search_handle, &wfd));
FindClose(search_handle);
-#endif
-#ifdef __UNIX__
+#else
DIR *dir = opendir(_path->s());
//hmmm: could check errno to determine what caused the problem.
if (!dir) return false;
DIR *dir = opendir(_path->s());
//hmmm: could check errno to determine what caused the problem.
if (!dir) return false;
@@
-209,9
+209,9
@@
bool directory::rescan()
if (add_it && !fnmatch(_pattern->s(), file, 0)) {
filename temp_name(*_path, file);
if (!temp_name.is_normal()) {
if (add_it && !fnmatch(_pattern->s(), file, 0)) {
filename temp_name(*_path, file);
if (!temp_name.is_normal()) {
-#ifdef DEBUG_DIRECTORY
+
//
#ifdef DEBUG_DIRECTORY
LOG(astring("skipping abnormal file: ") + temp_name);
LOG(astring("skipping abnormal file: ") + temp_name);
-#endif
+
//
#endif
entry = readdir(dir);
continue; // cannot be adding goofy named pipes etc; cannot manage those.
}
entry = readdir(dir);
continue; // cannot be adding goofy named pipes etc; cannot manage those.
}
@@
-234,10
+234,9
@@
bool directory::rescan()
bool directory::make_directory(const astring &path)
{
bool directory::make_directory(const astring &path)
{
-#if
def __UNIX__
+#if
defined(__UNIX__) || defined(__GNU_WINDOWS__)
int mk_ret = mkdir(path.s(), 0777);
int mk_ret = mkdir(path.s(), 0777);
-#endif
-#ifdef __WIN32__
+#else
int mk_ret = mkdir(path.s());
#endif
return !mk_ret;
int mk_ret = mkdir(path.s());
#endif
return !mk_ret;
@@
-245,10
+244,9
@@
bool directory::make_directory(const astring &path)
bool directory::remove_directory(const astring &path)
{
bool directory::remove_directory(const astring &path)
{
-#if
def __UNIX__
+#if
defined(__UNIX__) || defined(__GNU_WINDOWS__)
int rm_ret = rmdir(path.s());
int rm_ret = rmdir(path.s());
-#endif
-#ifdef __WIN32__
+#else
int rm_ret = rmdir(path.s());
#endif
return !rm_ret;
int rm_ret = rmdir(path.s());
#endif
return !rm_ret;
@@
-259,12
+257,13
@@
bool directory::recursive_create(const astring &directory_name)
FUNCDEF("recursive_create");
filename dir(directory_name);
string_array pieces;
FUNCDEF("recursive_create");
filename dir(directory_name);
string_array pieces;
- dir.separate(pieces);
+ bool rooted;
+ dir.separate(rooted, pieces);
for (int i = 0; i < pieces.length(); i++) {
// check each location along the way.
string_array partial = pieces.subarray(0, i);
filename curr;
for (int i = 0; i < pieces.length(); i++) {
// check each location along the way.
string_array partial = pieces.subarray(0, i);
filename curr;
- curr.join(partial); // this is our current location.
+ curr.join(
rooted,
partial); // this is our current location.
// make sure, if we see a drive letter component, that we call it
// a proper directory name.
if (curr.raw()[curr.raw().end()] == ':')
// make sure, if we see a drive letter component, that we call it
// a proper directory name.
if (curr.raw()[curr.raw().end()] == ':')
@@
-282,3
+281,4
@@
bool directory::recursive_create(const astring &directory_name)
}
} // namespace.
}
} // namespace.
+