why file copy function not working when we use the filename containing colon ?
-
i have seen that in my linux system that:
when i copy file that contain name like 1227202212:10:19
to my destination of usb pen drive it not copy the file.
srcPath : /home/raimbow/Rtime/Can/1227202212:10:40"
dstPath : /media/raimbow/4AFB-18C7/1227202212:10:40"
retValue = QFile::copy(srcPath, dstPath);
my above function return false .
what is solution to make it work ?
-
i have found that when we are going to do copy in pen drive at that time this file copy function not working. i have checked it. if we replace destination file name's colon with '_' its works fine
@Qt-embedded-developer said in why file copy function not working when we use the filename containing colon ?:
i have found that when we are going to do copy in pen drive at that time this file copy function not working. i have checked it. if we replace destination file name's colon with '_' its works fine
Well let's start with what file system your pen drive is formatted as? For example, if it's FAT32 or NTFS then I would imagine colons may be illegal in filenames, even under Linux?
First thing is to try this outside of Qt application....
-
Has nothing to do with colons but with your access rights or the file arealdy exists I would guess.
Works fine for me:#include <QtCore> int main(int argc, char **argv) { QCoreApplication app(argc, argv); QString src = "./test:1234"; QString dst = "./test:12345"; if (QFile::copy(src, dst)) { qDebug() << "Success"; } else { qDebug() << "Failed"; } return 0; }
Please create minimal, compilable examples before you post your problems here.
-
Has nothing to do with colons but with your access rights or the file arealdy exists I would guess.
Works fine for me:#include <QtCore> int main(int argc, char **argv) { QCoreApplication app(argc, argv); QString src = "./test:1234"; QString dst = "./test:12345"; if (QFile::copy(src, dst)) { qDebug() << "Success"; } else { qDebug() << "Failed"; } return 0; }
Please create minimal, compilable examples before you post your problems here.
i have found that when we are going to do copy in pen drive at that time this file copy function not working. i have checked it. if we replace destination file name's colon with '_' its works fine
-
i have seen that in my linux system that:
when i copy file that contain name like 1227202212:10:19
to my destination of usb pen drive it not copy the file.
srcPath : /home/raimbow/Rtime/Can/1227202212:10:40"
dstPath : /media/raimbow/4AFB-18C7/1227202212:10:40"
retValue = QFile::copy(srcPath, dstPath);
my above function return false .
what is solution to make it work ?
@Qt-embedded-developer
You/@Christian-Ehrlicher are using thestatic
function bool QFile::copy(const QString &fileName, const QString &newName). When that files you don't get any information as to why.I assume (untested) that if you use a the instance method bool QFile::copy(const QString &newName) then when it fails you can call QFileDevice::FileError QFileDevice::error() const on the
QFile
to find out why? -
i have found that when we are going to do copy in pen drive at that time this file copy function not working. i have checked it. if we replace destination file name's colon with '_' its works fine
@Qt-embedded-developer said in why file copy function not working when we use the filename containing colon ?:
i have found that when we are going to do copy in pen drive at that time this file copy function not working. i have checked it. if we replace destination file name's colon with '_' its works fine
Well let's start with what file system your pen drive is formatted as? For example, if it's FAT32 or NTFS then I would imagine colons may be illegal in filenames, even under Linux?
First thing is to try this outside of Qt application....
-
@Qt-embedded-developer said in why file copy function not working when we use the filename containing colon ?:
i have found that when we are going to do copy in pen drive at that time this file copy function not working. i have checked it. if we replace destination file name's colon with '_' its works fine
Well let's start with what file system your pen drive is formatted as? For example, if it's FAT32 or NTFS then I would imagine colons may be illegal in filenames, even under Linux?
First thing is to try this outside of Qt application....
@JonB said in why file copy function not working when we use the filename containing colon ?:
if it's FAT32 or NTFS then I would imagine colons may be illegal
Correct
-
And herein lies why you should "never" name files with anything but alphanumeric characters, and also avoid spaces while you're at it.