summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/files.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-17 07:37:27 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-17 07:37:27 +0000
commit1210d4439b7da2cea42e15892f7a09a03c6f0814 (patch)
tree8d1b24e2c887803607fa028ba950fd5da5cbd7b4 /crawl-ref/source/files.cc
parentd05ad02e6ca609c768a843eb62beda9f602e821a (diff)
downloadcrawl-ref-1210d4439b7da2cea42e15892f7a09a03c6f0814.tar.gz
crawl-ref-1210d4439b7da2cea42e15892f7a09a03c6f0814.zip
Apply DOS fixes to trunk.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6580 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/files.cc')
-rw-r--r--crawl-ref/source/files.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 4e9a019817..2dbce76869 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -213,6 +213,30 @@ static inline bool _is_good_filename(const std::string &s)
return (s != "." && s != "..");
}
+#if defined(DOS)
+// Abbreviates a given file name to DOS style "xxxxxx~1.txt".
+// Does not take into account files with differing suffixes or files
+// with a prepended path with more than one separator.
+// (It does handle all files included with the distribution except
+// changes.stone_soup.)
+bool get_dos_compatible_file_name(std::string *fname)
+{
+ std::string::size_type pos1 = fname->find("\\");
+ if (pos1 == std::string::npos)
+ pos1 = 0;
+
+ const std::string::size_type pos2 = fname->find(".txt");
+ // Name already fits DOS requirements, nothing to be done.
+ if (fname->substr(pos1, pos2).length() <= 8)
+ return (false);
+
+ *fname = fname->substr(0,pos1) + fname->substr(pos1, pos1 + 6) + "~1.txt";
+
+ return (true);
+}
+#endif
+
+
// Returns the names of all files in the given directory. Note that the
// filenames returned are relative to the directory.
std::vector<std::string> get_dir_files(const std::string &dirname)