1. Win32Lib copyFile() failure

I'm working on a backup app for my work. The one we have right now is
rather buggy, uses xcopy, and is written in VB. It fails on any
filename longer than 255 characters, due to using xcopy via the
command line. I'd like to rememdy this. I'm pretty sure copyFile() in
Win32Lib doesn't mind 255+ length filenames.

Here's a summary of the backup process:
  1. walk_dir() through all files, counting files, folders and sizes
  2. walk_dir() again, copyFile() or createDirectory() on each entry

createDirectory() successfully re-creates the directory tree, but
copyFile() only copies the first 3 files and fails on all the rest.

I can send the app to anyone who'd like to help, but I can't publicly post =
it.

~Greg

new topic     » topic index » view message » categorize

2. Re: Win32Lib copyFile() failure

AFAIK, win32lib uses CopyFileA API for the copyFile function, which is
limited by MAX_PATH ~= 260 chars for the file name. See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/copyfile.asp
.

If you want to copy longer filenames (up to 32K), you should use
CopyFileW which is the unicode version.


G> I'm working on a backup app for my work. The one we have right now is
G> rather buggy, uses xcopy, and is written in VB. It fails on any
G> filename longer than 255 characters, due to using xcopy via the
G> command line. I'd like to rememdy this. I'm pretty sure copyFile() in
G> Win32Lib doesn't mind 255+ length filenames.

G> Here's a summary of the backup process:
G>   1. walk_dir() through all files, counting files, folders and sizes
G>   2. walk_dir() again, copyFile() or createDirectory() on each entry

G> createDirectory() successfully re-creates the directory tree, but
G> copyFile() only copies the first 3 files and fails on all the rest.

G> I can send the app to anyone who'd like to help, but I can't publicly post
it.

G> ~Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: Win32Lib copyFile() failure

> AFAIK, win32lib uses CopyFileA API for the copyFile function, which is
> limited by MAX_PATH ~= 260 chars for the file name. See
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio=
/fs/copyfile.asp .
>
> If you want to copy longer filenames (up to 32K), you should use
> CopyFileW which is the unicode version.

OK, I found that, too. That's not my issue right now. My main issue is
some files just *don't* get copied, with no reason. The file names
could be 100 characters and they still fail..The only way I've got the
to copy is with open(), get_bytes() and puts(). But then I run out of
open file handles when I translate to C. Why, I don't know. I'm
closing all the files as I open them.

This is very frustrating, as I told my boss I'd have a working example
by Tuesday. I was also bragging how well Euphoria works, and now I'm
having issues.

~Greg

new topic     » goto parent     » topic index » view message » categorize

4. Re: Win32Lib copyFile() failure

Greg,

If you look under my name in the contributions you'll find an include file of
"extra" stuff not included in Win32Lib named WIN32EXT.EW.  In there you will find
a routine called SHFileOperation which will let you copy (among other things)
files.  Maybe give that one a try and see if it works.

Here's an example of using the routine (this one renames but I would suspect you
could just substitute FO_COPY for the second parameter (the operation)):

rtn_seq = SHFileOperation(getHandle(Main), FO_RENAME, local_temp_file,
					local_file, FOF_SILENT, 0, "")


Here's the link to the routine definition on MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shfileoperation.asp

You can also move multiple files with this routine although I don't have an
example.

HTH,

Jonas Temple
http://www.yhti.net/~jktemple

new topic     » goto parent     » topic index » view message » categorize

5. Re: Win32Lib copyFile() failure

> You can also move multiple files with this routine although I don't have =
an example.

Thanks, but I believe Aku fixed it. Some of the directories were not
being created. I thought I was creating them properly, but I guess I
missed them somehow. He added a couple lines of code that fixed the
problem.

Thank you everyone for your assistance.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu