Vor eine woche .... habe ich gesehen das
qt file.exists() & url.isValid() is true/true
beide sind einfach gleich...
dieses problem habe ich noch harmlos geloest mit...
Code: Alles auswählen
bool Config::IsNetFile( QString fullFileName )
{
if (fullFileName.startsWith("http://", Qt::CaseInsensitive) or
fullFileName.startsWith("ftp://", Qt::CaseInsensitive) or
fullFileName.startsWith("webdav://", Qt::CaseInsensitive) )
{
return true;
} else {
return false;
}
}
Doch nun das selbe mit dir und file ... fuer qt ist einfach beides dass selbe.
( f.exists() ) ist auch true bei dir...
mit php wenn ich frage ob es ein file ist oder ein dir bekomme ich eine richtige antwort..
um ein cache rekursiv su loeschen mit eine "leichtere" funktion ist es etwas so...
Code: Alles auswählen
bool Config::DownDirRemove( QString cleandir)
{
/* check on mac win PATH_SEPARATOR! */
/* to trust this function check to send test to "a:" and a:/dir/ (floppy)*/
file_put_contents_append("removefunc.log","1");
file_put_contents_append("removefunc.log",cleandir);
QDir dirqtmethod(cleandir);
if (dirqtmethod.isAbsolutePath(cleandir)) {
/*
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
*/
file_put_contents_append("removefunc.log","absolut path ok...");
DIR *pdir;
struct dirent *pent;
pdir=opendir(qtchars(cleandir));
if (!pdir){
return false;
}
errno=0;
while ((pent=readdir(pdir))){
/* translate to qt dir and file no */
QString onlyfilename = QString( "%1" ).arg( pent->d_name );
if (onlyfilename =="." or onlyfilename =="..") {
continue;
}
QString absolutelink = QString( "%1%2" ).arg( cleandir , pent->d_name ); /* dir no slasch on end! */
if (is_file(absolutelink)) {
file_put_contents_append("removefunc.log","found file... \""+absolutelink+"\" ");
if (qt_unlink(absolutelink)) {
file_put_contents_append("removefunc.log","found file... \""+absolutelink+"\" ");
} else {
file_put_contents_append("removefunc.log","not remove this file... \""+absolutelink+"\" ");
break;
}
} else {
DownDirRemove(QString( "%1/" ).arg( absolutelink ));
file_put_contents_append("removefunc.log","found dir...\""+absolutelink+"\" ");
}
}
if (errno){
file_put_contents_append("removefunc.log","erno true");
return false;
}
closedir(pdir);
/* dir end final */
if (dirqtmethod.rmdir(cleandir)) {
file_put_contents_append("removefunc.log","dir is confirm rmdir");
} else {
file_put_contents_append("removefunc.log","dir false confirm rmdir action ");
}
return true;
} else {
file_put_contents_append("removefunc.log","Not absolute path ...!");
return false;
}
}
Doch da bekommt mann lust mit einem
system("rm -rf /path"); daruber zu fahren... oder mit del rek auf window...
also ...
Code: Alles auswählen
bool is_file(QString fullFileName)
{
QFile f( fullFileName );
if ( f.exists() ) {
return true;
} else {
return false;
}
}