#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 <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
-#ifdef __WIN32__
- #include <direct.h>
-#endif
+//#ifdef _MSC_VER
+// #include <direct.h>
+//#endif
/*
#ifdef __WIN32__
{
char abs_path[MAX_ABS_PATH + 1];
abs_path[0] = '\0';
-#ifdef __WIN32__
- if (!_fullpath(abs_path, rel_path.s(), MAX_ABS_PATH)) return "";
- return abs_path;
-#else
+//#ifdef _MSC_VER
+// if (!_fullpath(abs_path, rel_path.s(), MAX_ABS_PATH)) return "";
+// return abs_path;
+//#else
if (!realpath(rel_path.s(), abs_path)) return "";
return abs_path;
-#endif
+//#endif
}
astring directory::current()
{
astring to_return("."); // failure result.
-#ifdef __WIN32__
- flexichar buffer[MAX_ABS_PATH + 1] = { '\0' };
- GetCurrentDirectory(MAX_ABS_PATH, buffer);
- to_return = from_unicode_temp(buffer);
-#else
+//#ifdef _MSC_VER
+// flexichar buffer[MAX_ABS_PATH + 1] = { '\0' };
+// GetCurrentDirectory(MAX_ABS_PATH, buffer);
+// to_return = from_unicode_temp(buffer);
+//#else
char buffer[MAX_ABS_PATH + 1] = { '\0' };
if (realpath(".", buffer)) to_return = buffer;
-#endif
+//#endif
return to_return;
}
_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;
}
} 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;
entry = readdir(dir);
}
closedir(dir);
-#endif
+//#endif
shell_sort(_files->access(), _files->length());
shell_sort(_folders->access(), _folders->length());
bool directory::make_directory(const astring &path)
{
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
int mk_ret = mkdir(path.s(), 0777);
-#endif
-#ifdef __WIN32__
+#else
int mk_ret = mkdir(path.s());
#endif
return !mk_ret;
bool directory::remove_directory(const astring &path)
{
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
int rm_ret = rmdir(path.s());
-#endif
-#ifdef __WIN32__
+#else
int rm_ret = rmdir(path.s());
#endif
return !rm_ret;
}
} // namespace.
+