Fix improvement for file permissions on Windows

This commit is contained in:
Christophe Dumez
2010-07-24 19:22:55 +00:00
parent fa6da97cf9
commit 185af18790
2 changed files with 25 additions and 18 deletions

View File

@@ -38,6 +38,7 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
#include <QPoint>
#include <QFile>
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/torrent_handle.hpp>
@@ -81,6 +82,15 @@ public:
return x;
}
static bool safeRemove(QString file_path) {
QFile MyFile(file_path);
if(!MyFile.exists()) return true;
// Make sure the permissions are ok
MyFile.setPermissions(MyFile.permissions()|QFile::ReadOwner|QFile::WriteOwner|QFile::ReadUser|QFile::WriteUser);
// Actually remove the file
return MyFile.remove();
}
static QString truncateRootFolder(boost::intrusive_ptr<torrent_info> t);
static QString truncateRootFolder(torrent_handle h);