static void create_test_files(void) { createTestFile("a.txt"); createTestFile("b.txt"); CreateDirectoryA("testdir", NULL); createTestFile("testdir\\c.txt"); createTestFile("testdir\\d.txt"); CreateDirectoryA("dest", NULL); }
static void test_AdvInstallFile(void) { HRESULT hr; HMODULE hmod; char CURR_DIR[MAX_PATH]; char destFolder[MAX_PATH]; hmod = LoadLibrary("setupapi.dll"); if (!hmod) { skip("setupapi.dll not present\n"); return; } FreeLibrary(hmod); GetCurrentDirectoryA(MAX_PATH, CURR_DIR); lstrcpyA(destFolder, CURR_DIR); lstrcatA(destFolder, "\\"); lstrcatA(destFolder, "dest"); createTestFile("source.txt"); /* try invalid source directory */ hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr); ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n"); /* try invalid source file */ hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr); ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n"); /* try invalid destination directory */ hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr); ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n"); /* try copying to nonexistent destination directory */ hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0); ok(hr == S_OK, "Expected S_OK, got %d\n", hr); ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n"); /* native windows screws up if the source file doesn't exist */ /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */ createTestFile("dest\\destination.txt"); hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0); ok(hr == S_OK, "Expected S_OK, got %d\n", hr); ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n"); ok(RemoveDirectoryA("dest"), "Expected dest to exist\n"); DeleteFileA("source.txt"); }
TEST(FileTransfer, DetectsUploadConnectionError) { CURL *curl; std::string source_file = "/accounts/1000/shared/documents/filetransfer_test.txt"; std::string target_url = "http://127.0.0.1/uploader.php"; std::string source_escaped(curl_easy_escape(curl, curl_easy_escape(curl, source_file.c_str(), 0), 0)); std::string target_escaped(curl_easy_escape(curl, curl_easy_escape(curl, target_url.c_str(), 0), 0)); std::string expected = "upload error 3 " + source_escaped + " " + target_escaped + " 0"; int file_result = createTestFile(source_file.c_str()); EXPECT_EQ(0, file_result); webworks::FileUploadInfo upload_info; upload_info.sourceFile = source_file; upload_info.targetURL = target_url; upload_info.mimeType = "text/plain"; upload_info.fileKey = "file"; upload_info.fileName = "test_file.txt"; upload_info.chunkedMode = 0; webworks::FileTransferCurl file_transfer; std::string result = file_transfer.Upload(&upload_info); EXPECT_EQ(expected, result); remove(source_file.c_str()); }
static void create_test_files(void) { int len; GetCurrentDirectoryA(MAX_PATH, CURR_DIR); len = lstrlenA(CURR_DIR); if(len && (CURR_DIR[len-1] == '\\')) CURR_DIR[len-1] = 0; createTestFile("a.txt"); createTestFile("b.txt"); CreateDirectoryA("testdir", NULL); createTestFile("testdir\\c.txt"); createTestFile("testdir\\d.txt"); }
// Tests the archive APIs for archiving/unarchiving a directory for GZIP // compression. This test specifically tests for the use case of changing // directory before archiving. TEST_F(TarTest, GZIPChangeDirectory) { // Create a top directory where the directory to be archived will be placed. const Path topDir("top_dir"); const Path testDir("test_dir"); const Path testFile(path::join(testDir, "testfile")); // Create a test file in the test directory. ASSERT_SOME(createTestFile(testFile, topDir)); // Archive the test directory. const Path outputTarFile("test_dir.tar"); AWAIT_ASSERT_READY(command::tar( testDir, outputTarFile, topDir, command::Compression::GZIP)); ASSERT_TRUE(os::exists(outputTarFile)); // Remove the top directory to make sure untar process creates new directory. ASSERT_SOME(os::rmdir(topDir)); ASSERT_FALSE(os::exists(topDir)); // Untar the tarball and verify that the original file is created. AWAIT_ASSERT_READY(command::untar(outputTarFile)); ASSERT_TRUE(os::exists(testDir)); // Verify that the top directory was not created. ASSERT_FALSE(os::exists(topDir)); // Verify that the content is same as original file. EXPECT_SOME_EQ("test", os::read(testFile)); }
// Tests the archive APIs for archiving/unarchiving a simple file for BZIP2 // compression. TEST_F(TarTest, BZIP2CompressFile) { // Create a test file. const Path testFile("testfile"); ASSERT_SOME(createTestFile(testFile)); // Archive the test file. const Path outputTarFile("test.tar"); AWAIT_ASSERT_READY(command::tar( testFile, outputTarFile, None(), command::Compression::BZIP2)); ASSERT_TRUE(os::exists(outputTarFile)); // Remove the test file to make sure untar process creates new test file. ASSERT_SOME(os::rm(testFile)); ASSERT_FALSE(os::exists(testFile)); // Untar the tarball and verify that the original file is created. AWAIT_ASSERT_READY(command::untar(outputTarFile)); ASSERT_TRUE(os::exists(testFile)); // Verify that the content is same as original file. EXPECT_SOME_EQ("test", os::read(testFile)); }
// OVS-2204: there were errors even on retry with a new connection which actually // should have succeeded - try to get to the bottom of that TEST_F(BackendInterfaceTest, retry_on_error) { const std::string oname("some-object"); const fs::path opath(path_ / oname); const yt::CheckSum cs(createTestFile(opath, 4096, "some pattern")); yt::CheckSum wrong_cs(1); ASSERT_NE(wrong_cs, cs); std::unique_ptr<be::BackendTestSetup::WithRandomNamespace> nspace(make_random_namespace()); const size_t retries = 7; ASSERT_LE(retries, cm_->capacity()); be::BackendInterfacePtr bi(cm_->newBackendInterface(nspace->ns(), retries)); ASSERT_THROW(bi->write(opath, oname, OverwriteObject::F, &wrong_cs), be::BackendInputException); ASSERT_EQ(retries + 1, cm_->size()); }
void JobTest::moveFileToOtherPartition() { kdDebug() << k_funcinfo << endl; const QString filePath = homeTmpDir() + "fileFromHome"; const QString dest = otherTmpDir() + "fileFromHome_moved"; createTestFile(filePath); moveLocalFile(filePath, dest); }
void JobTest::copyFileToSamePartition() { kdDebug() << k_funcinfo << endl; const QString filePath = homeTmpDir() + "fileFromHome"; const QString dest = homeTmpDir() + "fileFromHome_copied"; createTestFile(filePath); copyLocalFile(filePath, dest); }
static void createTestDirectory(const QString &path) { QDir dir; bool ok = dir.mkdir(path); if(!ok && !dir.exists()) kdFatal() << "couldn't create " << path << endl; createTestFile(path + "/testfile"); createTestSymlink(path + "/testlink"); setTimeStamp(path); }
void JobTest::copyFileToSystem(bool resolve_local_urls) { kdDebug() << k_funcinfo << resolve_local_urls << endl; extern KIO_EXPORT bool kio_resolve_local_urls; kio_resolve_local_urls = resolve_local_urls; const QString src = homeTmpDir() + "fileFromHome"; createTestFile(src); KURL u; u.setPath(src); KURL d = systemTmpDir(); d.addPath("fileFromHome_copied"); kdDebug() << "copying " << u << " to " << d << endl; // copy the file with file_copy KIO::FileCopyJob *job = KIO::file_copy(u, d); connect(job, SIGNAL(mimetype(KIO::Job *, const QString &)), this, SLOT(slotMimetype(KIO::Job *, const QString &))); bool ok = KIO::NetAccess::synchronousRun(job, 0); assert(ok); QString dest = realSystemPath() + "fileFromHome_copied"; assert(QFile::exists(dest)); assert(QFile::exists(src)); // still there { // do NOT check that the timestamp is the same. // It can't work with file_copy when it uses the datapump, // unless we use setModificationTime in the app code. } // Check mimetype kdDebug() << m_mimetype << endl; // There's no mimemagic determination in kio_file in kde3. Fixing this for kde4... assert(m_mimetype == "application/octet-stream"); // assert( m_mimetype == "text/plain" ); // cleanup and retry with KIO::copy() QFile::remove(dest); ok = KIO::NetAccess::dircopy(u, d, 0); assert(ok); assert(QFile::exists(dest)); assert(QFile::exists(src)); // still there { // check that the timestamp is the same (#79937) QFileInfo srcInfo(src); QFileInfo destInfo(dest); assert(srcInfo.lastModified() == destInfo.lastModified()); } // restore normal behavior kio_resolve_local_urls = true; }
void JobTest::get() { kdDebug() << k_funcinfo << endl; const QString filePath = homeTmpDir() + "fileFromHome"; createTestFile(filePath); KURL u; u.setPath(filePath); m_result = -1; KIO::StoredTransferJob *job = KIO::storedGet(u); connect(job, SIGNAL(result(KIO::Job *)), this, SLOT(slotGetResult(KIO::Job *))); kapp->eventLoop()->enterLoop(); assert(m_result == 0); // no error assert(m_data.size() == 11); assert(QCString(m_data) == "Hello world"); }
TEST_F(SignConversionTest, Int16) { AFfilehandle file = createTestFile(16); const int16_t data[] = { kMinInt16, 0, kMaxInt16 }; const int frameCount = sizeof (data) / sizeof (data[0]); AFframecount framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, data, frameCount); ASSERT_EQ(framesWritten, frameCount); afCloseFile(file); file = openTestFile(16); ASSERT_TRUE(file != NULL); uint16_t readData[frameCount]; AFframecount framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readData, frameCount); ASSERT_EQ(framesRead, frameCount); afCloseFile(file); const uint16_t expectedData[] = { 0, -kMinInt16, kMaxUInt16 }; for (int i=0; i<frameCount; i++) EXPECT_EQ(readData[i], expectedData[i]); }
// Main application entry poing int _tmain(int argc, _TCHAR* argv[]) { static const int SAMPLE_CNT = 20; DWORD fileSize[SAMPLE_CNT]; HANDLE fileHandle[SAMPLE_CNT]; ULONGLONG fileReadTime[SAMPLE_CNT]; // File size in bytes as a factor of pages fileSize[0] = _dwPageSize; for (int i = 1; i<SAMPLE_CNT; i++) { fileSize[i] = fileSize[i - 1] * 2; } // Create the files printf("Creating files...\n"); for (int i = 0; i<SAMPLE_CNT; i++) { fileHandle[i] = createTestFile(fileSize[i]); } // Get the read time for the files printf("Reading files...\n"); for (int i = 0; i<SAMPLE_CNT; i++) { FlushFileBuffers(fileHandle[i]); fileReadTime[i] = readFileTime(fileHandle[i], fileSize[i]); readFileCacheSize(); } // Output the results for (int i = 0; i<SAMPLE_CNT; i++) { printf("%I64u\n", fileReadTime[i]); } void readFileCachePeakSize(); while (1) { }; return 0; }
void pasteFileToOtherPartition() { const QString filePath = homeTmpDir() + "fileFromHome"; const QString dest = otherTmpDir() + "fileFromHome_copied"; QFile::remove(dest); createTestFile( filePath ); QMimeData* mimeData = new QMimeData; KUrl fileUrl(filePath); fileUrl.populateMimeData(mimeData); QApplication::clipboard()->setMimeData(mimeData); KIO::Job* job = KIO::pasteClipboard(otherTmpDir(), static_cast<QWidget*>(0)); job->setUiDelegate(0); bool ok = KIO::NetAccess::synchronousRun(job, 0); QVERIFY( ok ); QVERIFY( QFile::exists( dest ) ); QVERIFY( QFile::exists( filePath ) ); // still there }
TEST_F(PCMMappingTest, Double) { AFfilehandle file = createTestFile(AF_SAMPFMT_DOUBLE, 64); const double data[] = { -1, 0, 1 }; const int frameCount = sizeof (data) / sizeof (data[0]); AFframecount framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, data, frameCount); ASSERT_EQ(framesWritten, frameCount); afCloseFile(file); file = openTestFile(); ASSERT_TRUE(file != NULL); double slope = 2, intercept = 2, minClip = 0, maxClip = 4; afSetVirtualPCMMapping(file, AF_DEFAULT_TRACK, slope, intercept, minClip, maxClip); double readData[frameCount]; AFframecount framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readData, frameCount); ASSERT_EQ(framesRead, frameCount); afCloseFile(file); const double expectedData[] = { 0, 2, 4 }; for (int i=0; i<frameCount; i++) EXPECT_EQ(readData[i], expectedData[i]); }
void KIOPasteTest::testPasteJob_data() { QTest::addColumn<QList<QUrl> >("urls"); QTest::addColumn<bool>("data"); QTest::addColumn<bool>("cut"); QTest::addColumn<QString>("expectedFileName"); const QString file = m_dir + "/file"; createTestFile(file); QList<QUrl> urlFile = QList<QUrl>() << QUrl::fromLocalFile(file); QList<QUrl> urlDir = QList<QUrl>() << QUrl::fromLocalFile(m_dir); QTest::newRow("nothing") << QList<QUrl>() << false << false << QString(); QTest::newRow("copy_one_file") << urlFile << false << false << file.section('/', -1); QTest::newRow("copy_one_dir") << urlDir << false << false << m_dir.section('/', -1); QTest::newRow("cut_one_file") << urlFile << false << true << file.section('/', -1); QTest::newRow("cut_one_dir") << urlDir << false << true << m_dir.section('/', -1); // Shows a dialog! //QTest::newRow("data") << QList<QUrl>() << true << "output_file"; }
// OVS-2204: for some reason the count of open fds goes up after an error, but // valgrind does not report a leak. Try to figure our what's going on here. TEST_F(ConnectionManagerTest, limited_pool_on_errors) { std::async(std::launch::async, [&] { pin_to_cpu_0(); const std::string oname("some-object"); const fs::path opath(path_ / oname); const yt::CheckSum cs(createTestFile(opath, 4096, "some pattern")); yt::CheckSum wrong_cs(1); ASSERT_NE(wrong_cs, cs); std::unique_ptr<be::BackendTestSetup::WithRandomNamespace> nspace(make_random_namespace()); be::BackendInterfacePtr bi(bi_(nspace->ns())); const size_t count = 2 * cm_->capacity(); for (size_t i = 0; i < count; ++i) { ASSERT_THROW(bi->write(opath, oname, OverwriteObject::F, &wrong_cs), be::BackendInputException); } ASSERT_EQ(cm_->capacity() / cm_->shards(), cm_->size()); }).wait(); }
int _tmain(int argc, _TCHAR* argv[]) { static const int SAMPLE_CNT = 100; HANDLE fileHandle[SAMPLE_CNT]; int argInt = 0; int cnt = 0; while (++cnt < argc && argc != NULL){ argInt += ((int)*argv[cnt] - (int)'0') * 10 * cnt; } // Create the files for this process to read for (int i = 0; i<SAMPLE_CNT; i++) { fileHandle[i] = createTestFile(argInt, i); } // Get the read time for the files for (int i = 0; i<SAMPLE_CNT; i++) { readFileTime(fileHandle[i]); } Sleep(5); // Output the results to a file std::wstringstream outputFileNameStrm; outputFileNameStrm << FILE_DIRECTORY << L"\\Results_" << argInt; std::wofstream file; file.open(outputFileNameStrm.str().c_str()); file << "Average time (ns) " << _timeAvg.Average() << "\n"; file.close(); while (1) { } return 0; }
// Tests the archive APIs for a simple directory. TEST_F(TarTest, Directory) { const Path testDir("test_dir"); const Path testFile(path::join(testDir, "testfile")); // Create a test file in the test directory. ASSERT_SOME(createTestFile(testFile)); // Archive the test directory. const Path outputTarFile("test_dir.tar"); AWAIT_ASSERT_READY(command::tar(testDir, outputTarFile, None())); ASSERT_TRUE(os::exists(outputTarFile)); // Remove the test directory to make sure untar process creates new test file. ASSERT_SOME(os::rmdir(testDir)); ASSERT_FALSE(os::exists(testDir)); // Untar the tarball and verify that the original directory is created. AWAIT_ASSERT_READY(command::untar(outputTarFile)); ASSERT_TRUE(os::exists(testDir)); // Verify that the content is same as original file. EXPECT_SOME_EQ("test", os::read(testFile)); }
TEST_F(BackendObjectTest, checksum_mismatch) { const std::string oname("some-object"); const fs::path opath(path_ / oname); const yt::CheckSum cs(createTestFile(opath, 4096, "some pattern")); BackendInterfacePtr bi(bi_(nspace_->ns())); yt::CheckSum wrong_cs(1); ASSERT_NE(wrong_cs, cs); ASSERT_THROW(bi->write(opath, oname, OverwriteObject::F, &wrong_cs), BackendInputException); ASSERT_FALSE(bi->objectExists(oname)); }
/* initializes the tests */ static void init_shfo_tests(void) { int len; GetCurrentDirectoryA(MAX_PATH, CURR_DIR); len = lstrlenA(CURR_DIR); if(len && (CURR_DIR[len-1] == '\\')) CURR_DIR[len-1] = 0; createTestFile("test1.txt"); createTestFile("test2.txt"); createTestFile("test3.txt"); createTestFile("test_5.txt"); CreateDirectoryA("test4.txt", NULL); CreateDirectoryA("testdir2", NULL); CreateDirectoryA("testdir2\\nested", NULL); createTestFile("testdir2\\one.txt"); createTestFile("testdir2\\nested\\two.txt"); }
/* tests the FO_COPY action */ static void test_copy(void) { SHFILEOPSTRUCTA shfo, shfo2; CHAR from[MAX_PATH]; CHAR to[MAX_PATH]; FILEOP_FLAGS tmp_flags; DWORD retval; shfo.hwnd = NULL; shfo.wFunc = FO_COPY; shfo.pFrom = from; shfo.pTo = to; shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; shfo.hNameMappings = NULL; shfo.lpszProgressTitle = NULL; set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); ok(SHFileOperationA(&shfo), "Can't copy many files\n"); ok(!file_exists("test6.txt"), "The file is not copied - many files are " "specified as a target\n"); memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA)); shfo2.fFlags |= FOF_MULTIDESTFILES; set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); ok(!SHFileOperationA(&shfo2), "Can't copy many files\n"); ok(file_exists("test6.txt"), "The file is copied - many files are " "specified as a target\n"); DeleteFileA("test6.txt"); DeleteFileA("test7.txt"); RemoveDirectoryA("test8.txt"); /* number of sources do not correspond to number of targets */ set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0"); ok(SHFileOperationA(&shfo2), "Can't copy many files\n"); ok(!file_exists("test6.txt"), "The file is not copied - many files are " "specified as a target\n"); set_curr_dir_path(from, "test1.txt\0"); set_curr_dir_path(to, "test4.txt\0"); ok(!SHFileOperationA(&shfo), "Prepare test to check how directories are copied recursively\n"); ok(file_exists("test4.txt\\test1.txt"), "The file is copied\n"); set_curr_dir_path(from, "test?.txt\0"); set_curr_dir_path(to, "testdir2\0"); ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n"); ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n"); ok(!SHFileOperationA(&shfo), "Files and directories are copied to directory\n"); ok(file_exists("testdir2\\test1.txt"), "The file is copied\n"); ok(file_exists("testdir2\\test4.txt"), "The directory is copied\n"); ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is copied\n"); clean_after_shfo_tests(); init_shfo_tests(); shfo.fFlags |= FOF_FILESONLY; ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n"); ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n"); ok(!SHFileOperationA(&shfo), "Files are copied to other directory\n"); ok(file_exists("testdir2\\test1.txt"), "The file is copied\n"); ok(!file_exists("testdir2\\test4.txt"), "The directory is copied\n"); clean_after_shfo_tests(); init_shfo_tests(); set_curr_dir_path(from, "test1.txt\0test2.txt\0"); ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n"); ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n"); ok(!SHFileOperationA(&shfo), "Files are copied to other directory\n"); ok(file_exists("testdir2\\test1.txt"), "The file is copied\n"); ok(file_exists("testdir2\\test2.txt"), "The file is copied\n"); clean_after_shfo_tests(); /* Copying multiple files with one not existing as source, fails the entire operation in Win98/ME/2K/XP, but not in 95/NT */ init_shfo_tests(); tmp_flags = shfo.fFlags; set_curr_dir_path(from, "test1.txt\0test10.txt\0test2.txt\0"); ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n"); ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n"); retval = SHFileOperationA(&shfo); if (!retval) /* Win 95/NT returns success but copies only the files up to the nonexistent source */ ok(file_exists("testdir2\\test1.txt"), "The file is not copied\n"); else { /* Win 98/ME/2K/XP fail the entire operation with return code 1026 if one source file does not exist */ ok(retval == 1026, "Files are copied to other directory\n"); ok(!file_exists("testdir2\\test1.txt"), "The file is copied\n"); } ok(!file_exists("testdir2\\test2.txt"), "The file is copied\n"); shfo.fFlags = tmp_flags; /* copy into a nonexistent directory */ init_shfo_tests(); shfo.fFlags = FOF_NOCONFIRMMKDIR; set_curr_dir_path(from, "test1.txt\0"); set_curr_dir_path(to, "nonexistent\\notreal\\test2.txt\0"); retval= SHFileOperation(&shfo); ok(!retval, "Error copying into nonexistent directory\n"); ok(file_exists("nonexistent"), "nonexistent not created\n"); ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal not created\n"); ok(file_exists("nonexistent\\notreal\\test2.txt"), "Directory not created\n"); ok(!file_exists("nonexistent\\notreal\\test1.txt"), "test1.txt should not exist\n"); /* a relative dest directory is OK */ clean_after_shfo_tests(); init_shfo_tests(); shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0"; shfo.pTo = "testdir2\0"; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1 to exist\n"); /* try to copy files to a file */ clean_after_shfo_tests(); init_shfo_tests(); shfo.pFrom = from; shfo.pTo = to; set_curr_dir_path(from, "test1.txt\0test2.txt\0"); set_curr_dir_path(to, "test3.txt\0"); retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); ok(!file_exists("test3.txt\\test2.txt"), "Expected test3.txt\\test2.txt to not exist\n"); /* try to copy many files to nonexistent directory */ DeleteFile(to); shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(DeleteFile("test3.txt\\test1.txt"), "Expected test3.txt\\test1.txt to exist\n"); ok(DeleteFile("test3.txt\\test2.txt"), "Expected test3.txt\\test1.txt to exist\n"); ok(RemoveDirectory(to), "Expected test3.txt to exist\n"); /* send in FOF_MULTIDESTFILES with too many destination files */ init_shfo_tests(); shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0"; shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0"; shfo.fFlags |= FOF_NOERRORUI | FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\a.txt to not exist\n"); /* send in FOF_MULTIDESTFILES with too many destination files */ shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0"; shfo.pTo = "e.txt\0f.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); ok(!file_exists("e.txt"), "Expected e.txt to not exist\n"); /* use FOF_MULTIDESTFILES with files and a source directory */ shfo.pFrom = "test1.txt\0test2.txt\0test4.txt\0"; shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(DeleteFile("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n"); ok(DeleteFile("testdir2\\b.txt"), "Expected testdir2\\b.txt to exist\n"); ok(RemoveDirectory("testdir2\\c.txt"), "Expected testdir2\\c.txt to exist\n"); /* try many dest files without FOF_MULTIDESTFILES flag */ shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0"; shfo.pTo = "a.txt\0b.txt\0c.txt\0"; shfo.fAnyOperationsAborted = FALSE; shfo.fFlags &= ~FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(!file_exists("a.txt"), "Expected a.txt to not exist\n"); /* try a glob */ shfo.pFrom = "test?.txt\0"; shfo.pTo = "testdir2\0"; shfo.fFlags &= ~FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n"); /* try a glob with FOF_FILESONLY */ clean_after_shfo_tests(); init_shfo_tests(); shfo.pFrom = "test?.txt\0"; shfo.fFlags |= FOF_FILESONLY; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n"); ok(!file_exists("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to not exist\n"); /* try a glob with FOF_MULTIDESTFILES and the same number * of dest files that we would expect */ clean_after_shfo_tests(); init_shfo_tests(); shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0"; shfo.fFlags &= ~FOF_FILESONLY; shfo.fFlags |= FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\test1.txt to not exist\n"); ok(!RemoveDirectory("b.txt"), "b.txt should not exist\n"); /* copy one file to two others, second is ignored */ clean_after_shfo_tests(); init_shfo_tests(); shfo.pFrom = "test1.txt\0"; shfo.pTo = "b.txt\0c.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n"); /* copy two file to three others, all fail */ shfo.pFrom = "test1.txt\0test2.txt\0"; shfo.pTo = "b.txt\0c.txt\0d.txt\0"; retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n"); /* copy one file and one directory to three others */ shfo.pFrom = "test1.txt\0test4.txt\0"; shfo.pTo = "b.txt\0c.txt\0d.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n"); ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n"); /* copy a directory with a file beneath it, plus some files */ createTestFile("test4.txt\\a.txt"); shfo.pFrom = "test4.txt\0test1.txt\0"; shfo.pTo = "testdir2\0"; shfo.fFlags &= ~FOF_MULTIDESTFILES; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(DeleteFile("testdir2\\test1.txt"), "Expected newdir\\test1.txt to exist\n"); ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n"); ok(RemoveDirectory("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to exist\n"); /* copy one directory and a file in that dir to another dir */ shfo.pFrom = "test4.txt\0test4.txt\\a.txt\0"; shfo.pTo = "testdir2\0"; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n"); ok(DeleteFile("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n"); /* copy a file in a directory first, and then the directory to a nonexistent dir */ shfo.pFrom = "test4.txt\\a.txt\0test4.txt\0"; shfo.pTo = "nonexistent\0"; retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); ok(!file_exists("nonexistent\\test4.txt"), "Expected nonexistent\\test4.txt to not exist\n"); DeleteFile("test4.txt\\a.txt"); /* destination is same as source file */ shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0"; shfo.pTo = "b.txt\0test2.txt\0c.txt\0"; shfo.fAnyOperationsAborted = FALSE; shfo.fFlags = FOF_NOERRORUI | FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); ok(retval == ERROR_NO_MORE_SEARCH_HANDLES, "Expected ERROR_NO_MORE_SEARCH_HANDLES, got %ld\n", retval); ok(!shfo.fAnyOperationsAborted, "Expected no operations to be aborted\n"); ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); ok(!file_exists("c.txt"), "Expected c.txt to not exist\n"); /* destination is same as source directory */ shfo.pFrom = "test1.txt\0test4.txt\0test3.txt\0"; shfo.pTo = "b.txt\0test4.txt\0c.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); ok(!file_exists("c.txt"), "Expected c.txt to not exist\n"); /* copy a directory into itself, error displayed in UI */ shfo.pFrom = "test4.txt\0"; shfo.pTo = "test4.txt\\newdir\0"; shfo.fFlags &= ~FOF_MULTIDESTFILES; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(!RemoveDirectory("test4.txt\\newdir"), "Expected test4.txt\\newdir to not exist\n"); /* copy a directory to itself, error displayed in UI */ shfo.pFrom = "test4.txt\0"; shfo.pTo = "test4.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); /* copy a file into a directory, and the directory into itself */ shfo.pFrom = "test1.txt\0test4.txt\0"; shfo.pTo = "test4.txt\0"; shfo.fAnyOperationsAborted = FALSE; shfo.fFlags |= FOF_NOCONFIRMATION; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(DeleteFile("test4.txt\\test1.txt"), "Expected test4.txt\\test1.txt to exist\n"); /* copy a file to a file, and the directory into itself */ shfo.pFrom = "test1.txt\0test4.txt\0"; shfo.pTo = "test4.txt\\a.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval); ok(!file_exists("test4.txt\\a.txt"), "Expected test4.txt\\a.txt to not exist\n"); /* copy a nonexistent file to a nonexistent directory */ shfo.pFrom = "e.txt\0"; shfo.pTo = "nonexistent\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == 1026, "Expected 1026, got %ld\n", retval); ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n"); ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n"); }
static void test_FDIIsCabinet(void) { ERF erf; BOOL ret; HFDI hfdi; INT_PTR fd; FDICABINETINFO cabinfo; char temp[] = "temp.txt"; char extract[] = "extract.cab"; create_test_files(); create_cab_file(); hfdi = FDICreate(fdi_alloc, fdi_free, fdi_open, fdi_read, fdi_write, fdi_close, fdi_seek, cpuUNKNOWN, &erf); ok(hfdi != NULL, "Expected non-NULL context\n"); /* native crashes if hfdi or cabinfo are NULL or invalid */ /* invalid file handle */ ZeroMemory(&cabinfo, sizeof(FDICABINETINFO)); SetLastError(0xdeadbeef); ret = FDIIsCabinet(hfdi, -1, &cabinfo); ok(ret == FALSE, "Expected FALSE, got %d\n", ret); ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); ok(cabinfo.cbCabinet == 0, "Expected 0, got %d\n", cabinfo.cbCabinet); ok(cabinfo.cFiles == 0, "Expected 0, got %d\n", cabinfo.cFiles); ok(cabinfo.cFolders == 0, "Expected 0, got %d\n", cabinfo.cFolders); ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet); ok(cabinfo.setID == 0, "Expected 0, got %d\n", cabinfo.setID); createTestFile("temp.txt"); fd = fdi_open(temp, 0, 0); /* file handle doesn't point to a cabinet */ ZeroMemory(&cabinfo, sizeof(FDICABINETINFO)); SetLastError(0xdeadbeef); ret = FDIIsCabinet(hfdi, fd, &cabinfo); ok(ret == FALSE, "Expected FALSE, got %d\n", ret); ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(cabinfo.cbCabinet == 0, "Expected 0, got %d\n", cabinfo.cbCabinet); ok(cabinfo.cFiles == 0, "Expected 0, got %d\n", cabinfo.cFiles); ok(cabinfo.cFolders == 0, "Expected 0, got %d\n", cabinfo.cFolders); ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet); ok(cabinfo.setID == 0, "Expected 0, got %d\n", cabinfo.setID); fdi_close(fd); DeleteFileA("temp.txt"); /* try a real cab */ fd = fdi_open(extract, 0, 0); ZeroMemory(&cabinfo, sizeof(FDICABINETINFO)); SetLastError(0xdeadbeef); ret = FDIIsCabinet(hfdi, fd, &cabinfo); ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(cabinfo.cFiles == 4, "Expected 4, got %d\n", cabinfo.cFiles); ok(cabinfo.cFolders == 1, "Expected 1, got %d\n", cabinfo.cFolders); ok(cabinfo.setID == 0xbeef, "Expected 0xbeef, got %d\n", cabinfo.setID); todo_wine { ok(cabinfo.cbCabinet == 182, "Expected 182, got %d\n", cabinfo.cbCabinet); ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet); } fdi_close(fd); FDIDestroy(hfdi); delete_test_files(); }
int main( int argc, char* argv[]) { # define DEFAULT_PATHNAME "lockTest.test" const char* pathname = DEFAULT_PATHNAME; off_t size = 8192; int status = EXIT_SUCCESS; int c; # define DEFAULT_MAX_INTERVAL 50 useconds_t maxInterval = DEFAULT_MAX_INTERVAL; while ((c = getopt(argc, argv, "f:i:")) != -1) { switch(c) { case 'f': { pathname = optarg; break; } case 'i': { unsigned long max; int nbytes; if (sscanf(optarg, "%lu %n", &max, &nbytes) != 1 || optarg[nbytes] != 0 || max < 0) { (void)fprintf(stderr, "Invalid maximum sleep interval \"%s\"\n", optarg); status = EXIT_FAILURE; } maxInterval = (useconds_t)max; break; } case '?': (void)fprintf(stderr, "Unrecognized option \"%c\"\n", optopt); status = EXIT_FAILURE; break; } } if (optind < argc) { (void)fprintf(stderr, "Unrecognized argument \"%s\"\n", argv[optind]); status = EXIT_FAILURE; } if (status == EXIT_FAILURE) { (void)fprintf(stderr, "Usage: %s [-f pathname] [-i maxInterval]\n" " where:\n" " -f pathname Pathname of test file (default: \"./%s\").\n" " -i maxInterval Maximum sleep interval between fcntl()\n" " calls in integral microseconds (default: %d).\n", argv[0], DEFAULT_PATHNAME, DEFAULT_MAX_INTERVAL); } else { status = EXIT_FAILURE; if (createTestFile(pathname, size)) { pid_t pid = startChildLocker(pathname, size, maxInterval); if (pid != -1) { pid = startChildLocker(pathname, size, maxInterval); if (pid != -1) { pause(); status = EXIT_SUCCESS; } } } } exit(status); }
static void test_Extract(void) { SESSION session; HRESULT res; struct FILELIST *node; /* native windows crashes if * - invalid parameters are sent in * - you call EXTRACT_EXTRACTFILES without calling * EXTRACT_FILLFILELIST first or at the same time */ /* try to extract all files */ ZeroMemory(&session, sizeof(SESSION)); lstrcpyA(session.Destination, "dest"); session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES; res = pExtract(&session, "extract.cab"); node = session.FileList; ok(res == S_OK, "Expected S_OK, got %d\n", res); ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_NONE, "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError); ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount); ok(session.Operation == (EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES), "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n"); ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n"); ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n"); ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n"); ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n"); ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n"); free_file_list(&session); /* try fill file list operation */ ZeroMemory(&session, sizeof(SESSION)); lstrcpyA(session.Destination, "dest"); session.Operation = EXTRACT_FILLFILELIST; res = pExtract(&session, "extract.cab"); node = session.FileList; ok(res == S_OK, "Expected S_OK, got %d\n", res); ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_NONE, "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError); ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount); ok(session.Operation == EXTRACT_FILLFILELIST, "Expected EXTRACT_FILLFILELIST, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n"); ok(check_list(&node, "testdir\\d.txt", TRUE), "list entry wrong\n"); ok(check_list(&node, "testdir\\c.txt", TRUE), "list entry wrong\n"); ok(check_list(&node, "b.txt", TRUE), "list entry wrong\n"); ok(check_list(&node, "a.txt", TRUE), "list entry wrong\n"); /* try extract files operation once file list is filled */ session.Operation = EXTRACT_EXTRACTFILES; res = pExtract(&session, "extract.cab"); node = session.FileList; ok(res == S_OK, "Expected S_OK, got %d\n", res); ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_NONE, "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError); ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount); ok(session.Operation == EXTRACT_EXTRACTFILES, "Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n"); ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n"); ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n"); ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n"); ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n"); ok(RemoveDirectoryA("dest"), "Expected dest to exist\n"); ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n"); /* Extract does not extract files if the dest dir does not exist */ res = pExtract(&session, "extract.cab"); node = session.FileList; ok(res == S_OK, "Expected S_OK, got %d\n", res); ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_NONE, "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError); ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount); ok(session.Operation == EXTRACT_EXTRACTFILES, "Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n"); ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n"); ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n"); /* remove two of the files in the list */ node = session.FileList->next; session.FileList->next = session.FileList->next->next; free_file_node(node); free_file_node(session.FileList->next->next); session.FileList->next->next = NULL; session.FilterList = NULL; CreateDirectoryA("dest", NULL); res = pExtract(&session, "extract.cab"); node = session.FileList; ok(res == S_OK, "Expected S_OK, got %d\n", res); ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_NONE, "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError); ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount); ok(session.Operation == EXTRACT_EXTRACTFILES, "Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n"); ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n"); ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n"); ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n"); ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(!check_list(&node, "a.txt", FALSE), "list entry wrong\n"); free_file_list(&session); session.Operation = EXTRACT_FILLFILELIST; session.FileList = NULL; res = pExtract(&session, "extract.cab"); node = session.FileList; ok(res == S_OK, "Expected S_OK, got %d\n", res); ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_NONE, "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError); ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount); ok(session.Operation == EXTRACT_FILLFILELIST, "Expected EXTRACT_FILLFILELIST, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n"); ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n"); ok(check_list(&node, "testdir\\d.txt", TRUE), "list entry wrong\n"); ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(!check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(!check_list(&node, "a.txt", FALSE), "list entry wrong\n"); session.Operation = 0; res = pExtract(&session, "extract.cab"); node = session.FileList; ok(res == S_OK, "Expected S_OK, got %d\n", res); ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_NONE, "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError); ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount); ok(session.Operation == 0, "Expected 0, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n"); ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n"); ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n"); ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n"); ok(check_list(&node, "testdir\\d.txt", TRUE), "list entry wrong\n"); ok(check_list(&node, "testdir\\c.txt", TRUE), "list entry wrong\n"); ok(check_list(&node, "b.txt", TRUE), "list entry wrong\n"); ok(check_list(&node, "a.txt", TRUE), "list entry wrong\n"); session.Operation = 0; session.FilterList = session.FileList; res = pExtract(&session, "extract.cab"); node = session.FileList; ok(res == S_OK, "Expected S_OK, got %d\n", res); ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_NONE, "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError); ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount); ok(session.Operation == 0, "Expected 0, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n"); ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n"); ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n"); ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n"); ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n"); node = session.FilterList; ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n"); free_file_list(&session); /* cabinet does not exist */ ZeroMemory(&session, sizeof(SESSION)); lstrcpyA(session.Destination, "dest"); session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES; res = pExtract(&session, "nonexistent.cab"); node = session.FileList; ok(res == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %08x\n", res); ok(session.Error.erfOper == FDIERROR_CABINET_NOT_FOUND, "Expected FDIERROR_CABINET_NOT_FOUND, got %d\n", session.Error.erfOper); ok(session.FileSize == 0, "Expected 0, got %d\n", session.FileSize); ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError); ok(session.FileCount == 0, "Expected 0, got %d\n", session.FileCount); ok(session.Operation == (EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES), "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!*session.CurrentFile, "Expected empty string, got %s\n", session.CurrentFile); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n"); ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n"); ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n"); ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry should not exist\n"); ok(!check_list(&node, "b.txt", FALSE), "list entry should not exist\n"); ok(!check_list(&node, "a.txt", FALSE), "list entry should not exist\n"); free_file_list(&session); /* first file exists */ createTestFile("dest\\a.txt"); SetFileAttributes("dest\\a.txt", FILE_ATTRIBUTE_READONLY); ZeroMemory(&session, sizeof(SESSION)); lstrcpyA(session.Destination, "dest"); session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES; res = pExtract(&session, "extract.cab"); node = session.FileList; todo_wine { ok(res == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) || res == E_FAIL, "Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) or E_FAIL, got %08x\n", res); ok(session.FileSize == 6, "Expected 6, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_USER_ABORT, "Expected FDIERROR_USER_ABORT, got %d\n", session.Error.erfOper); ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError); ok(session.FileCount == 1, "Expected 1, got %d\n", session.FileCount); ok(!lstrcmpA(session.CurrentFile, "dest\\a.txt"), "Expected dest\\a.txt, got %s\n", session.CurrentFile); } ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Operation == (EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES), "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n"); todo_wine { ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n"); ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n"); ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n"); ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry should not exist\n"); ok(!check_list(&node, "b.txt", FALSE), "list entry should not exist\n"); } ok(!check_list(&node, "a.txt", FALSE), "list entry should not exist\n"); free_file_list(&session); SetFileAttributesA("dest\\a.txt", FILE_ATTRIBUTE_NORMAL); DeleteFileA("dest\\a.txt"); /* third file exists */ createTestFile("dest\\testdir\\c.txt"); SetFileAttributes("dest\\testdir\\c.txt", FILE_ATTRIBUTE_READONLY); ZeroMemory(&session, sizeof(SESSION)); lstrcpyA(session.Destination, "dest"); session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES; res = pExtract(&session, "extract.cab"); node = session.FileList; todo_wine { ok(res == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) || res == E_FAIL, "Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) or E_FAIL, got %08x\n", res); ok(session.FileSize == 26, "Expected 26, got %d\n", session.FileSize); ok(session.Error.erfOper == FDIERROR_USER_ABORT, "Expected FDIERROR_USER_ABORT, got %d\n", session.Error.erfOper); ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError); ok(session.FileCount == 3, "Expected 3, got %d\n", session.FileCount); ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\c.txt"), "Expected dest\\c.txt, got %s\n", session.CurrentFile); } ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType); ok(session.Operation == (EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES), "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation); ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination); ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved); ok(!session.FilterList, "Expected empty filter list\n"); ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n"); ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n"); ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n"); todo_wine { ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n"); ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n"); } ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n"); ok(!check_list(&node, "b.txt", FALSE), "list entry wrong\n"); ok(!check_list(&node, "a.txt", TRUE), "list entry wrong\n"); free_file_list(&session); SetFileAttributesA("dest\\testdir\\c.txt", FILE_ATTRIBUTE_NORMAL); DeleteFileA("dest\\testdir\\c.txt"); ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n"); ok(RemoveDirectoryA("dest"), "Expected dest to exist\n"); }
int __cdecl main(int argc, char *argv[]) { WIN32_FIND_DATAW findFileData; WIN32_FIND_DATAW findFileData_02; HANDLE hFind = NULL; BOOL bRc = FALSE; DWORD dwBytesWritten; WCHAR* wTempPtr = NULL; if (0 != PAL_Initialize(argc,argv)) { return FAIL; } removeAll(); // // find a file that exists // if(createTestFile(szFindName) == FALSE) { PAL_Terminate(); return FAIL; } if(createTestFile(szFindName_02) == FALSE) { PAL_Terminate(); return FAIL; } wTempPtr = convert((LPSTR)szFindName); hFind = FindFirstFileW(wTempPtr, &findFileData); free(wTempPtr); if (hFind == INVALID_HANDLE_VALUE) { removeAll(); Fail("FindNextFileW: ERROR -> Unable to find \"%s\"\n", szFindName); } else { bRc = FindNextFileW(hFind, &findFileData); if (bRc != FALSE) { removeAll(); Fail("FindNextFileW: ERROR -> Found a file that doesn't exist.\n"); } } // // find a directory that exists // wTempPtr = convert((LPSTR)szDirName); bRc = CreateDirectoryW(wTempPtr, NULL); free (wTempPtr); if (bRc == FALSE) { removeAll(); Fail("FindNextFileW: ERROR -> Failed to create the directory \"%s\"\n", szDirName); } wTempPtr = convert((LPSTR)szDirName_02); bRc = CreateDirectoryW(wTempPtr, NULL); free (wTempPtr); if (bRc == FALSE) { removeAll(); Fail("FindNextFileW: ERROR -> Failed to create the directory " "\"%s\"\n", szDirName_02); } wTempPtr = convert((LPSTR)szDirName); hFind = FindFirstFileW(wTempPtr, &findFileData); free (wTempPtr); if (hFind == INVALID_HANDLE_VALUE) { removeAll(); Fail("FindNextFileW: ERROR. FindFirstFileW was unable " "to find \"%s\"\n", szDirName); } else { bRc = FindNextFileW(hFind, &findFileData); if (bRc != FALSE) { removeAll(); Fail("FindNextFileW: ERROR -> Found a directory that " "doesn't exist.\n"); } } // // find a file using wild cards // wTempPtr = convert((LPSTR)szFindNameWldCard_01); hFind = FindFirstFileW(wTempPtr, &findFileData); free(wTempPtr); if (hFind == INVALID_HANDLE_VALUE) { removeAll(); Fail("FindNextFileW: ERROR -> FindFirstFileW was unable to " "find \"%s\"\n", szFindNameWldCard_01); } else { bRc = FindNextFileW(hFind, &findFileData_02); if (bRc == FALSE) { removeAll(); Fail("FindNextFileW: ERROR -> Unable to find another file.\n"); } else { // validate we found the correct file if (wcscmp(findFileData_02.cFileName, findFileData.cFileName) == 0) { removeAll(); Fail("FindNextFileW: ERROR -> Found the same file \"%S\".\n", findFileData.cFileName); } } } // // find a directory using wild cards // wTempPtr = convert((LPSTR)szDirNameWldCard); hFind = FindFirstFileW(wTempPtr, &findFileData); free(wTempPtr); if (hFind == INVALID_HANDLE_VALUE) { removeAll(); Fail("FindNextFileW: ERROR -> Unable to find \"%s\"\n", szDirNameWldCard); } else { bRc = FindNextFileW(hFind, &findFileData_02); if (bRc == FALSE) { removeAll(); Fail("FindNextFileW: ERROR -> Unable to find another directory.\n"); } else { // validate we found the correct directory if (wcscmp(findFileData_02.cFileName, findFileData.cFileName) == 0) { removeAll(); Fail("FindNextFileW: ERROR -> Found the same directory " "\"%S\".\n", findFileData.cFileName); } } } // // attempt to write to the hFind handle (which should fail) // bRc = WriteFile(hFind, "this is a test", 10, &dwBytesWritten, NULL); if (bRc == TRUE) { removeAll(); Fail("FindNextFileW: ERROR -> Able to write to a FindNextFileW " "handle.\n"); } removeAll(); PAL_Terminate(); return PASS; }
int __cdecl main(int argc, char *argv[]) { WIN32_FIND_DATAW findFileData; WIN32_FIND_DATAW findFileData_02; HANDLE hFind = NULL; BOOL bRc = FALSE; char* pTemp = NULL; if (0 != PAL_Initialize(argc,argv)) { return FAIL; } /* do some clean up just to be sure */ removeAll(); /* FindClose a null handle */ if(FindClose(NULL)!=0) { Fail("FindClose: ERROR -> Closing a NULL handle succeeded.\n"); } /* find a file that exists */ if(createTestFile(szFindName) == FALSE) { removeAll(); PAL_TerminateEx(FAIL); return FAIL; } if(createTestFile(szFindName_02) == FALSE) { removeAll(); PAL_TerminateEx(FAIL); return FAIL; } if(createTestFile(szFindName_03) == FALSE) { removeAll(); PAL_TerminateEx(FAIL); return FAIL; } // close a FindFirstFileW handle hFind = FindFirstFileW(szFindName, &findFileData); if (hFind == INVALID_HANDLE_VALUE) { pTemp = convertC((WCHAR*)szFindName); Trace("FindClose: ERROR -> Unable to find \"%s\"\n", pTemp); free(pTemp); removeAll(); PAL_TerminateEx(FAIL); return FAIL; } else { bRc = FindClose(hFind); if (bRc == FALSE) { removeAll(); Fail("FindClose: ERROR -> Unable to close a valid" " FindFirstFileW handle.\n"); } } hFind = FindFirstFileW(szFindName, &findFileData); if (hFind == INVALID_HANDLE_VALUE) { pTemp = convertC((WCHAR*)szFindName); Trace("FindClose: ERROR -> Unable to find \"%s\"\n", pTemp); free(pTemp); removeAll(); PAL_TerminateEx(FAIL); return FAIL; } else { bRc = FindNextFileW(hFind, &findFileData); if (bRc != FALSE) { removeAll(); Fail("FindClose: ERROR -> Found a file that doesn't exist.\n"); } else { bRc = FindClose(hFind); if (bRc == FALSE) { removeAll(); Fail("FindClose: ERROR -> Unable to close a valid " "FindNextFileW handle.\n"); } } } /* find a directory that exists */ bRc = CreateDirectoryW(szDirName, NULL); if (bRc == FALSE) { pTemp = convertC((WCHAR*)szDirName); Trace("FindClose: ERROR -> Failed to create the directory \"%s\"\n", pTemp); free(pTemp); removeAll(); PAL_TerminateEx(FAIL); return FAIL; } bRc = CreateDirectoryW(szDirName_02, NULL); if (bRc == FALSE) { pTemp = convertC((WCHAR*)szDirName_02); Trace("FindClose: ERROR -> Failed to create the directory \"%s\"\n", pTemp); free(pTemp); removeAll(); PAL_TerminateEx(FAIL); return FAIL; } hFind = FindFirstFileW(szDirName, &findFileData); if (hFind == INVALID_HANDLE_VALUE) { pTemp = convertC((WCHAR*)szDirName); Trace("FindClose: ERROR. FindFirstFileW was unable to find \"%s\"\n", pTemp); free(pTemp); removeAll(); PAL_TerminateEx(FAIL); return FAIL; } else { bRc = FindClose(hFind); if (bRc == FALSE) { removeAll(); Fail("FindClose: ERROR -> Unable to close a valid" " FindFirstFileW handle of a directory.\n"); } } /* find a file using wild cards */ hFind = FindFirstFileW(szFindNameWldCard_01, &findFileData); if (hFind == INVALID_HANDLE_VALUE) { pTemp = convertC((WCHAR*)szFindNameWldCard_01); Trace("FindClose: ERROR -> FindFirstFileW was unable to find \"%s\"\n", pTemp); free(pTemp); removeAll(); PAL_TerminateEx(FAIL); return FAIL; } else { bRc = FindNextFileW(hFind, &findFileData_02); if (bRc == FALSE) { removeAll(); Fail("FindClose: ERROR -> Unable to find another file.\n"); } else { bRc = FindClose(hFind); if (bRc == FALSE) { removeAll(); Fail("FindClose: ERROR -> Unable to close a valid" " FindNextFileW handle.\n"); } } } /* find a directory using wild cards */ hFind = FindFirstFileW(szDirNameWldCard, &findFileData); if (hFind == INVALID_HANDLE_VALUE) { pTemp = convertC((WCHAR*)szDirNameWldCard); Trace("FindClose: ERROR -> Unable to find \"%s\"\n", pTemp); free(pTemp); removeAll(); PAL_TerminateEx(FAIL); return FAIL; } else { bRc = FindNextFileW(hFind, &findFileData_02); if (bRc == FALSE) { removeAll(); Fail("FindClose: ERROR -> Unable to find another directory.\n"); } else { bRc = FindClose(hFind); if (bRc == FALSE) { removeAll(); Fail("FindClose: ERROR -> Unable to close a valid" " FindNextFileW handle of a directory.\n"); } } } removeAll(); PAL_Terminate(); return PASS; }