GLBasic forum

Main forum => GLBasic - en => Topic started by: 9940 on 2009-Jul-28

Title: inline call to rename()
Post by: 9940 on 2009-Jul-28
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 ?

Code (glbasic) Select

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*)'

Title: Re: inline call to rename()
Post by: MrTAToad on 2009-Jul-28
Try :

Code (glbasic) Select
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...
Title: Re: inline call to rename()
Post by: 9940 on 2009-Jul-28
Thx  :good:

                                                                                                                 
However I don't think it is hard to make a command like RENAME() integrated in glbasic.
Title: Re: inline call to rename()
Post by: MrTAToad on 2009-Jul-28
You can actually do it with COPYFILE and KILLFILE...
Title: Re: inline call to rename()
Post by: 9940 on 2009-Jul-28
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

Title: Re: inline call to rename()
Post by: MrTAToad on 2009-Jul-28
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 :)
Title: Re: inline call to rename()
Post by: 9940 on 2009-Jul-28
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")
Title: Re: inline call to rename()
Post by: MrTAToad on 2009-Jul-28
Quite true there.
Title: Re: inline call to rename()
Post by: Kitty Hello on 2009-Jul-29
V7 has MOVEFILE.
Title: Re: inline call to rename()
Post by: 9940 on 2009-Jul-29
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 ?
Title: Re: inline call to rename()
Post by: Hatonastick on 2009-Jul-29
Hey Gernot, I can't see that one in the v7 help file?
Title: Re: inline call to rename()
Post by: Kitty Hello on 2009-Jul-29
oops - on my todo. I'll add that. And add that DOESFILEEXIST checks for the existence of a directory.
Title: Re: inline call to rename()
Post by: Hatonastick on 2009-Jul-29
Fantastic stuff! :)
Title: Re: inline call to rename()
Post by: ampos on 2012-Mar-16
Is there a way I can RENAME a FOLDER in all (mobile) devices?
Title: Re: inline call to rename()
Post by: MrTAToad on 2012-Mar-16
You should be able to call the C rename function, although you may need to change permissions for some devices...
Title: Re: inline call to rename()
Post by: ampos on 2012-Mar-16
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?
Title: Re: inline call to rename()
Post by: MrTAToad on 2012-Mar-16
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 :)
Title: inline call to rename()
Post by: Kitty Hello on 2012-Mar-17
Oh dear. I'll add that soon.
Title: Re: inline call to rename()
Post by: ampos on 2012-Mar-17
Dont worry, MrToad inline code works fine, at least in windows :D and if you remember that "c:\" is "c:/"  =D
Title: Re: inline call to rename()
Post by: Cliff3D on 2017-Jul-27
Was MOVEFILE ever implemented?

Cheers,

Cliff
Title: Re: inline call to rename()
Post by: Kitty Hello on 2017-Aug-04
GLBasic V15 will have MOVEFILE.