Exemplo n.º 1
0
    bool FileManager::save(Image & image, const std::string & path, bool createSymbol)
    {
        // -------------------------
        // Create filename and directories if not exist
        
        unsigned long found = path.find("/");
        while(found != -1)
        {
            std::string subDirectory = path.substr(0, found);
            createDirectoryIfNotExists(subDirectory);
            found = path.find("/",found+1);
        }
        // -------------------------
        // Call save method on image
        
        std::string pathToImage = getBaseDirectory() + "/" + path;
        if(image.save(pathToImage))
        {
            if(createSymbol)
            {
                std::string link = SYMBOL_DIRECTORY + path;
                symlink(pathToImage.c_str(), link.c_str());
            }

            return true;
        }
        else
        {
            return false;
        }
            
    }
bool CommonFunctions::copyFile(QString file) {
    QFileInfo fileInfo(file);
    if (checkIfFileExists(fileInfo)) {
        return true;
    } else {
        if (createDirectoryIfNotExists(fileInfo.dir())) {
            return QFile::copy(":/App/assets/database/database.db", file);
        } else {
            return false;
        }
    }
}
Exemplo n.º 3
0
 bool FileManager::createDirectoryIfNotExists(char * dir)
 {
     std::string d = std::string(dir);
     return createDirectoryIfNotExists(d);
 }