summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindra/llcommon/llfile.cpp2
-rw-r--r--indra/llcommon/tests/llfile_test.cpp51
2 files changed, 52 insertions, 1 deletions
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index 3780a26cbe..ec4e15c690 100755
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -201,7 +201,7 @@ static void find_locking_process(const std::string& filename)
else
{
std::string tf(TEMP);
- tf += "\\handle.tmp";
+ tf += "handle.tmp";
// http://technet.microsoft.com/en-us/sysinternals/bb896655
std::string cmd(STRINGIZE("handle \"" << filename
// "openfiles /query /v | fgrep -i \"" << filename
diff --git a/indra/llcommon/tests/llfile_test.cpp b/indra/llcommon/tests/llfile_test.cpp
index 9f2a9b2988..18dfe08876 100644
--- a/indra/llcommon/tests/llfile_test.cpp
+++ b/indra/llcommon/tests/llfile_test.cpp
@@ -50,6 +50,12 @@ namespace tut
return append_filename(tempdir, std::string("test_dir"));
}
+ static std::filesystem::path get_testdir_unicode(const std::filesystem::path& tempdir)
+ {
+ // Example Unicode directory name: "test_ユニコード_dir"
+ return append_filename(tempdir, std::string("test_\xE3\x83\xA6\xE3\x83\x8B\xE3\x82\xB3\xE3\x83\xBC\xE3\x83\x89_dir"));
+ }
+
struct llfile_test
{
std::filesystem::path tempdir = LLFile::tmpdir();
@@ -250,4 +256,49 @@ namespace tut
ensure("LLFile constructor should not have been able to open the file in the non-existing directory", !file);
ensure("error_code from LLFile constructor should indicate an error", (bool)ec);
}
+
+ template<> template<>
+ void llfile_test_object_t::test<5>()
+ {
+ // Test file and directory operations with Unicode paths and filenames
+ std::filesystem::path testdir_unicode = get_testdir_unicode(tempdir);
+
+ // Clean up any previous test artifacts
+ clear_entire_dir(testdir_unicode);
+ ensure("Unicode test directory should not exist", !LLFile::exists(testdir_unicode.string()));
+
+ // Create the Unicode directory
+ int rc = LLFile::mkdir(testdir_unicode.string());
+ ensure("LLFile::mkdir() failed for Unicode directory", rc == 0);
+ ensure("Unicode test directory should exist", LLFile::isdir(testdir_unicode.string()));
+
+ // Unicode filename: "ファイル_テスト.dat" (means "file_test.dat" in Japanese)
+ std::string unicode_filename = "\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB_\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88\x0A.dat";
+ std::filesystem::path testfile_unicode = testdir_unicode;
+ testfile_unicode.append(unicode_filename);
+
+ ensure("Unicode test file should not exist", !LLFile::exists(testfile_unicode.string()));
+
+ // Write to the Unicode file
+ const char* testdata = "unicode_testdata";
+ S64 bytes = LLFile::write(testfile_unicode.string(), testdata, 0, strlen(testdata));
+ ensure("LLFile::write() did not write correctly to Unicode file", bytes == (S64)strlen(testdata));
+ ensure("Unicode test file should exist", LLFile::exists(testfile_unicode.string()));
+ ensure("Unicode test file should be a file", LLFile::isfile(testfile_unicode.string()));
+
+ // Read back the data
+ char buffer[64] = {};
+ bytes = LLFile::read(testfile_unicode.string(), buffer, 0, sizeof(buffer));
+ ensure("LLFile::read() did not read correctly from Unicode file", bytes == (S64)strlen(testdata));
+ ensure_memory_matches("LLFile::read() did not read correct Unicode data", testdata, (U32)bytes, buffer, (U32)bytes);
+
+ // Remove the file and directory
+ rc = LLFile::remove(testfile_unicode.string());
+ ensure("LLFile::remove() failed for Unicode file", rc == 0);
+ ensure("Unicode test file should not exist after removal", !LLFile::exists(testfile_unicode.string()));
+
+ rc = LLFile::remove(testdir_unicode.string());
+ ensure("LLFile::remove() failed for Unicode directory", rc == 0);
+ ensure("Unicode test directory should not exist after removal", !LLFile::exists(testdir_unicode.string()));
+ }
} // namespace tut