static void fileSelect(llist entries) { LST_HEAD* l; char topDirectory[1024]; char currentDirectory[1024]; char key[1024]; FILE_ENTRY* f; struct stat buf; int i; int flag = 0; strcpy(currentDirectory, cgi_val(entries, "CurrentDirectory")); strcpy(key, cgi_val(entries, "Key")); strcat(currentDirectory, "/"); strcat(currentDirectory, key); memset(&buf, 0, sizeof(buf)); #ifdef WIN32 i = _stat(currentDirectory, &buf); if (i == 0) { flag = ((buf.st_mode & _S_IFDIR) != 0); } #else i = stat(currentDirectory, &buf); if (i == 0) { flag = (S_ISDIR(buf.st_mode)); } #endif if (flag == 0) fileToHTML(currentDirectory); else directoryToHTML(currentDirectory); }
bool exportToHTML::toHTML(const QString &catName,const QString &dataPath) { QString path = dataPath + "/UserData/" + catName; // Path of the category to be exported. QString pathToExport = dataPath + "/UserHTML/" + catName; // Path to store the exported HTML QDir dir(path); if(!dir.exists(pathToExport)) { if(!dir.mkpath(pathToExport)) { QMessageBox::critical(this,tr("Error"),tr("Could not create user data folder.\nCheck if you have write permissions."),QMessageBox::Ok); return false; } } QStringList list= dir.entryList(QDir::NoDotAndDotDot|QDir::Files,QDir::Time|QDir::Reversed); for(QStringList::Iterator iter = list.begin(); iter != list.end(); ++iter) { fileToHTML(*iter,path+"/"+*iter,pathToExport); // Convert file at "path+..." to file.html at datapath. } createIndexFile(pathToExport,catName); return true; }