wxCopyFile when dir dont exist.
wxCopyFile when dir dont exist.
Hello. If i have wxCopyFile(source, dest) and dir of destination file don’t exist, wxCopyFile can make destination dir automatically?
Thank you.
Jim
Thank you.
Jim
Re: wxCopyFile when dir dont exist.
Better use wxFileName https://docs.wxwidgets.org/trunk/classwx_file_name.html
Check first if the dir exists: wxFileName::DirExists(), and create it if not: wxFileName::Mkdir(...)
Check first if the dir exists: wxFileName::DirExists(), and create it if not: wxFileName::Mkdir(...)
Re: wxCopyFile when dir dont exist.
Yes this is the way. But dirName is like dri1/dir2/dir3 ... and as i see wxMkdir dont make subdirs...
Only if dirName is only one dir name.
Thank you
Jim
Only if dirName is only one dir name.
Thank you
Jim
Code: Select all
wxFileName xx(dest);
wxString dirName =xx.GetPath();
if (!wxDirExists(dirName))
wxMkdir(dirName);
Re: wxCopyFile when dir dont exist.
Did you try what Manolo suggested, i.e. calling wxFileName::Mkdir() with flags containing wxPATH_MKDIR_FULL?
Re: wxCopyFile when dir dont exist.
My program runs in /home/a/myfolder/ and i want to make the dir...
dirName=/home/a/video/home/a/Desktop/folder/to/
but wxMkdir(dirName,wxPATH_MKDIR_FULL) don’t makes it.
What i have wrong?
dirName=/home/a/video/home/a/Desktop/folder/to/
but wxMkdir(dirName,wxPATH_MKDIR_FULL) don’t makes it.
What i have wrong?
Re: wxCopyFile when dir dont exist.
What is the joke?
I don’t understand, really.
I am try to make a clone of a file in other place, relative to existing dir(/home/a/video).
The file is at /home/a/Desktop/folder/to/.
All that for non destructive process.
I is really important to construct the new directory and then copy the file.
The program's dir is at other place.
Thank you.
Jim.
I don’t understand, really.
I am try to make a clone of a file in other place, relative to existing dir(/home/a/video).
The file is at /home/a/Desktop/folder/to/.
All that for non destructive process.
I is really important to construct the new directory and then copy the file.
The program's dir is at other place.
Thank you.
Jim.
Last edited by dkaip on Thu Sep 27, 2018 7:19 am, edited 3 times in total.
Re: wxCopyFile when dir dont exist.
Add a wxLogMessage( dirName ) to check that it actually contains what you expect.
Use the source, Luke!
Re: wxCopyFile when dir dont exist.
Two people suggested that you should try wxFileName::Mkdir() instead of ::wxMkdir(). Additionally, you have been provided a direct link to the documentation of the said method as well as the value you should use for its flag parameter.dkaip wrote:What is the joke? I don’t understand, really.
Yet, you still kept talking about ::wxMkdir() so I assumed this was some kind of an elaborate joke I am not on...
On MSW, wxFileName::Mkdir() works as expected, i.e.,
Code: Select all
wxFileName("C:\\a\\b\\c\\d\\").Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
If it does not work like that on Linux (assuming there are no permissions issues), you should have said so (and report it as a bug).
Last edited by PB on Thu Sep 27, 2018 7:22 am, edited 1 time in total.
Re: wxCopyFile when dir dont exist.
Ok my wrong, i am new to wxWidgets. I will make as you say.
So i make it and nothing happens(there are no permissions issues).
Maybe because some directories have Unicode characters?
Trying wxMessageBox(dirName); take
/home/a/Βίντεο/home/a/Επιφάνεια εργασίας
There is some problem maybe with Unicode..
But even the code bellow, to convert to Unicode nothing...
Even if all characters of dirName are ASCII...
/home/a/home/a/myfolder
Thank you
Jim.
So i make it and nothing happens(there are no permissions issues).
Maybe because some directories have Unicode characters?
Trying wxMessageBox(dirName); take
/home/a/Βίντεο/home/a/Επιφάνεια εργασίας
There is some problem maybe with Unicode..
But even the code bellow, to convert to Unicode nothing...
Code: Select all
wxString dirName =xx.GetPath();
dirName=wxString(dirName.mbc_str(),wxConvUTF8);
wxMessageBox(dirName);
if (!wxDirExists(dirName))
if( wxFileName::Mkdir(dirName,wxPATH_MKDIR_FULL))wxMessageBox(dest);
/home/a/home/a/myfolder
Thank you
Jim.
Re: wxCopyFile when dir dont exist.
Ok it works as PB make.
The method is wxFileName(("/home/a/home/a/myfolder/")).Mkdir(wxS_DIR_DEFAULT,wxPATH_MKDIR_FULL);
If / don’t exist at first then puts home/a/home/a/myfolder in current dir.
If / don’t exist at last the myfolder dir dont make it.
Thank you.
Jim.
The method is wxFileName(("/home/a/home/a/myfolder/")).Mkdir(wxS_DIR_DEFAULT,wxPATH_MKDIR_FULL);
If / don’t exist at first then puts home/a/home/a/myfolder in current dir.
If / don’t exist at last the myfolder dir dont make it.
Thank you.
Jim.
Re: wxCopyFile when dir dont exist.
Code: Select all
wxFileName::Mkdir(dirName,wxPATH_MKDIR_FULL)
Should be:
Code: Select all
wxFileName::Mkdir( dirName, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL )
Use the source, Luke!