inline call to rename()

Previous topic - Next topic

9940

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


MrTAToad

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...

9940

Thx  :good:

                                                                                                                 
However I don't think it is hard to make a command like RENAME() integrated in glbasic.

MrTAToad

You can actually do it with COPYFILE and KILLFILE...

9940

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


MrTAToad

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 :)

9940

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")

MrTAToad


Kitty Hello


9940

#9
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 ?

Hatonastick

Hey Gernot, I can't see that one in the v7 help file?

Kitty Hello

oops - on my todo. I'll add that. And add that DOESFILEEXIST checks for the existence of a directory.

Hatonastick


ampos

Is there a way I can RENAME a FOLDER in all (mobile) devices?
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

MrTAToad

You should be able to call the C rename function, although you may need to change permissions for some devices...