I wish to call rename() because glbasic don't have anything to rename or move files/dirs.
But I get an error. Someone know how can I implement it correctly ?
INLINE
}
extern int rename(const char *_old, const char *_new);
namespace __GLBASIC__
{
ENDINLINE
FUNCTION inline_Rename: old$, new$
INLINE
rename(old_Str.c_str(), new_Str.c_str());
ENDINLINE
ENDFUNCTION
gpc_temp1.o:gpc_temp1.cpp:(.text+0x248): undefined reference to `rename(char const*, char const*)'
Try :
INLINE
}
extern "C" int rename(const char *_old, const char *_new);
namespace __GLBASIC__
{
ENDINLINE
FUNCTION inline_Rename: old$, new$
INLINE
rename(old_Str.c_str(), new_Str.c_str());
ENDINLINE
ENDFUNCTION
And see if it works. Which is does...
Thx :good:
However I don't think it is hard to make a command like RENAME() integrated in glbasic.
You can actually do it with COPYFILE and KILLFILE...
Quote
Quote
function copy: a$, b$
copyfile a$, b$
killfile a$
endfunction
Yes, it works.. but if you have a huge file/dir it may take long time
and may not be enough space
Even if Gernot included it, a large file could take a long time anyway.
What you need to do is put a copying system in a seperate thread or something like that :)
Quote
Even if Gernot included it, a large file could take a long time anyway.
No, beacause rename can move a file without copy it. Ex: RENAME("file1.dat", "..\\file1.dat")
Quite true there.
V7 has MOVEFILE.
If you are using the C func rename() directly, MOVEFILE could be an incorrect name because it can move directory too.
Is DOESDIREXIST() implemented in v7 ?
Hey Gernot, I can't see that one in the v7 help file?
oops - on my todo. I'll add that. And add that DOESFILEEXIST checks for the existence of a directory.
Fantastic stuff! :)
Is there a way I can RENAME a FOLDER in all (mobile) devices?
You should be able to call the C rename function, although you may need to change permissions for some devices...
Quote from: Kitty Hello on 2009-Jul-29
V7 has MOVEFILE.
Was MOVEFILE ever implemented?
QuoteYou should be able to call the C rename function, although you may need to change permissions for some devices...
I will try it later. Anyway, in "public" directory in iOS or Android, will i need special permisions?
QuoteWas MOVEFILE ever implemented?
No...
QuoteI will try it later. Anyway, in "public" directory in iOS or Android, will i need special permisions?[/quote[
Hopefully not :)
Oh dear. I'll add that soon.
Dont worry, MrToad inline code works fine, at least in windows :D and if you remember that "c:\" is "c:/" =D
Was MOVEFILE ever implemented?
Cheers,
Cliff
GLBasic V15 will have MOVEFILE.