summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libw32c.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2010-09-17 01:53:41 +0200
committerAdam Borowski <kilobyte@angband.pl>2010-09-17 01:56:35 +0200
commite65b29e9f2a9a79731f38787384f9c877eec430f (patch)
treedf729dca05bd679dccf7cc336974e4795099ce47 /crawl-ref/source/libw32c.cc
parent0fac9b0ec9f22978b94594373d65c5a70a4441fd (diff)
downloadcrawl-ref-e65b29e9f2a9a79731f38787384f9c877eec430f.tar.gz
crawl-ref-e65b29e9f2a9a79731f38787384f9c877eec430f.zip
Handle filenames with non-ascii characters.
Only iostreams functions are left; on Windows they don't support Unicode so a workaround will be needed.
Diffstat (limited to 'crawl-ref/source/libw32c.cc')
-rw-r--r--crawl-ref/source/libw32c.cc102
1 files changed, 0 insertions, 102 deletions
diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc
index ba6ded9334..52b234f691 100644
--- a/crawl-ref/source/libw32c.cc
+++ b/crawl-ref/source/libw32c.cc
@@ -963,112 +963,10 @@ int get_number_of_cols()
return (screensize.X);
}
-#ifdef TARGET_COMPILER_VC
-struct DIR
-{
- public:
- DIR()
- : hFind(INVALID_HANDLE_VALUE),
- wfd_valid(false)
- {
- memset(&wfd, 0, sizeof(wfd));
- memset(&entry, 0, sizeof(entry));
- }
-
- ~DIR()
- {
- if (hFind != INVALID_HANDLE_VALUE)
- {
- FindClose(hFind);
- }
- }
-
- bool init(const char* szFind)
- {
- // Check that it's a directory, first.
- {
- const DWORD dwAttr = GetFileAttributes(szFind);
- if (dwAttr == INVALID_FILE_ATTRIBUTES)
- return (false);
- if ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0)
- return (false);
- }
-
- find = szFind;
- find += "\\*";
-
- hFind = FindFirstFileA(find.c_str(), &wfd);
- wfd_valid = (hFind != INVALID_HANDLE_VALUE);
- return (true);
- }
-
- dirent* readdir()
- {
- if (!wfd_valid)
- return 0;
-
- _convert_wfd_to_dirent();
- wfd_valid = (bool) FindNextFileA(hFind, &wfd);
-
- return (&entry);
- }
-
- private:
- void _convert_wfd_to_dirent()
- {
- entry.d_reclen = sizeof(dirent);
- entry.d_namlen = strlen(entry.d_name);
- entry.d_type = (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- ? DT_DIR : DT_REG;
- strncpy(entry.d_name, wfd.cFileName, sizeof(entry.d_name));
- entry.d_name[sizeof(entry.d_name)-1] = 0;
- }
-
- private:
- HANDLE hFind;
- bool wfd_valid;
- WIN32_FIND_DATA wfd;
- std::string find;
- dirent entry;
- // since opendir calls FindFirstFile, we need a means of telling the
- // first call to readdir that we already have a file.
- // that's the case iff this is == 0; we use a counter rather than a
- // flag because that allows keeping statistics.
- int num_entries_scanned;
-};
-
-
-DIR* opendir(char* path)
-{
- DIR* d = new DIR();
- if (d->init(path))
- {
- return d;
- }
- else
- {
- delete d;
- return 0;
- }
-}
-
-dirent* readdir(DIR* d)
-{
- return d->readdir();
-}
-
-int closedir(DIR* d)
-{
- delete d;
- return 0;
-}
-
int ftruncate(int fp, int size)
{
ASSERT(false); // unimplemented
return 0;
}
-#endif /* #ifdef TARGET_COMPILER_VC */
-
#endif /* #if defined(TARGET_OS_WINDOWS) && !defined(USE_TILE) */