/// Loads data for testing the 'testFileName' file.
    void loadTestFileData(const char* testFileName) {

        fileName = getTestFileFullPath(SAMPLE_FILES_DIR, testFileName);
        const char* fileContent = loadTestFile(SAMPLE_FILES_DIR, testFileName, true);  // must be binary mode!
        int fileSize = (int)fgetsize(fileName.c_str());

        const WCHAR* wtestFileName = toWideChar(testFileName);
        
        FileData fileData;
        fileData.setName(wtestFileName);
        fileData.setSize(fileSize);
        fileData.setBody(fileContent, fileSize);

        unsigned long tstamp = getFileModTime(fileName);
        StringBuffer modTime = unixTimeToString(tstamp, true);  // file's mod time is already in UTC
        WString wmodTime;
        wmodTime = modTime;
        fileData.setModified(wmodTime);

        fileDataContent = fileData.format();
        fileDataSize = (int)strlen(fileDataContent);

        delete [] wtestFileName;
        delete [] fileContent;
    }
Exemplo n.º 2
0
    /// Util method: creates a OMA file data object
    FileData createFileData(const char* inputFileName) {

        // Read the input file
        char* content = NULL;
        size_t len;
        StringBuffer inFile = getTestFileFullPath(TEST_INPUT_DIR, inputFileName);
        bool fileLoaded = readFile(inFile.c_str(), &content, &len, true);
        CPPUNIT_ASSERT_MESSAGE("Failed to load test file", fileLoaded);

        FileData file;
        file.setBody(content, (int)len);
        file.setSize((int)len);
        WString wname;
        wname = inputFileName;
        file.setName(wname.c_str());

        delete [] content;
        return file;
    }