- Handle paths with (~, ., ..) properly

This commit is contained in:
Christophe Dumez
2009-12-22 10:29:39 +00:00
parent c334439df6
commit 50e620daf2
5 changed files with 67 additions and 33 deletions

View File

@@ -205,7 +205,7 @@ public:
public slots:
void updateDiskSpaceLabels() {
long long available = misc::freeDiskSpaceOnPath(savePathTxt->text());
long long available = misc::freeDiskSpaceOnPath(misc::expandPath(savePathTxt->text()));
lbl_disk_space->setText(misc::friendlyUnit(available));
// Determine torrent size
@@ -235,9 +235,10 @@ public slots:
void on_browseButton_clicked(){
QString dir;
QDir saveDir(savePathTxt->text());
if(saveDir.exists()){
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), savePathTxt->text());
QString save_path = misc::expandPath(savePathTxt->text());
QDir saveDir(save_path);
if(!save_path.isEmpty() && saveDir.exists()){
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath());
}else{
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath());
}
@@ -261,11 +262,11 @@ public slots:
}
void on_OkButton_clicked(){
QDir savePath(savePathTxt->text());
if(savePathTxt->text().trimmed().isEmpty()){
QMessageBox::critical(0, tr("Empty save path"), tr("Please enter a save path"));
return;
}
QDir savePath(misc::expandPath(savePathTxt->text()));
// Check if savePath exists
if(!savePath.exists()){
if(!savePath.mkpath(savePath.path())){