31#define CSIDL_APPDATA 0x001a
34#ifndef CSIDL_LOCAL_APPDATA
35#define CSIDL_LOCAL_APPDATA 0x001c
40bool moveFile( QString oldName, QString newName)
45 if(!rootDir.rename( oldName, newName))
54 rootDir.remove(oldName);
61bool copyFile(QString oldFilePath, QString newFilePath)
64 if(oldFilePath.compare(newFilePath) == 0)
68 QFile oldFile(oldFilePath);
69 QFile newFile(newFilePath);
70 bool openOld = oldFile.open( QIODevice::ReadOnly );
71 bool openNew = newFile.open( QIODevice::WriteOnly );
74 if(!openOld || !openNew) {
return false; }
77 uint BUFFER_SIZE = 16000;
78 char*
buffer =
new char[BUFFER_SIZE];
79 while(!oldFile.atEnd())
81 Q_ULONG len = oldFile.readBlock(
buffer, BUFFER_SIZE );
82 newFile.writeBlock(
buffer, len );
93bool getWindowsFolderLocation(FOLDER_TYPE type, QString& path)
99 case APPLICATION_DATA:
100 folder = CSIDL_APPDATA;
break;
101 case LOCAL_SETTINGS_APPLICATION_DATA:
102 folder = CSIDL_LOCAL_APPDATA;
break;
113 unsigned short folderPath[MAX_PATH];
114 if( SHGetSpecialFolderPathW(0, folderPath, folder,
false) )
115 path = QString::fromUcs2( (ushort*)folderPath );
121 char folderPath[MAX_PATH];
122 if( SHGetSpecialFolderPathA( 0, folderPath, folder,
false ) )
123 path = QString::fromLocal8Bit( folderPath );
130 if( (!success) && (type == LOCAL_SETTINGS_APPLICATION_DATA) )
131 return getWindowsFolderLocation( APPLICATION_DATA, path );
139 filename.replace( QChar(
' '),
"_" );
140 filename.replace(
"<",
"" );
141 filename.replace(
">",
"" );
142 filename.replace(
"&",
"and" );
143 filename.replace(
"\"",
"" );
144 filename.replace(
"\'",
"" );
145 filename.replace(
"?",
"" );