Recent

Author Topic: SOLVED: Linux: Copyfile Problems  (Read 9294 times)

GuiGuy

  • New member
  • *
  • Posts: 8
SOLVED: Linux: Copyfile Problems
« on: September 27, 2009, 12:48:30 am »
Hi,
I have years of Delphi & Pascal programming behind me, but on Windows. I am now dabbling with Linux.

I thought I'd write a little utility to copy files in a particular order.  essentially

Quote
var f1, f2 : String;
      r : BOOLEAN;
begin

  f1 := <sourcepathandfilename>;  
  f2 := <destinationpathandfilename>;  

if fileexist(f1) AND directoryexists(ExtractFileDir(f2)) then
               r := copyfile(f1,f2);

f1 and f2 assignment syntax is consistent with the linux OS requirements.

However, copyfile falls over with an unknown exception if the filenames include spaces.

I have experimented with enclosing the file name in quotes and doublequotes but this doesn't help. Renaming the files is not an option.

Can someone point me in the direction of what needs to be none to manipulate unusually named files under linux.

PS I have the code working fine under Windows.

SOLUTION: Nevermind, it was a simple matter to roll my own function using the fileread/ filewrite routines.  It's a pity though that the generic copyfile doesn't work properly.



« Last Edit: September 27, 2009, 01:52:44 am by GuiGuy »
The GuyGui

Bart

  • Hero Member
  • *****
  • Posts: 3912
    • Bart en Mariska's Webstek
Re: SOLVED: Linux: Copyfile Problems
« Reply #1 on: September 27, 2009, 01:04:00 pm »
Did you try escaping the spaces: "name with spaces" -> "name\ with\ spaces" ?

Bart

GuiGuy

  • New member
  • *
  • Posts: 8
Re: SOLVED: Linux: Copyfile Problems
« Reply #2 on: September 27, 2009, 01:26:30 pm »
Did you try escaping the spaces: "name with spaces" -> "name\ with\ spaces" ?

Yes. While that allowed some files to be processed, the majority failed with the "unknown" exception.

But, as I wrote, no matter. the fileread > filewrite got me out of trouble. And I didn't have to waste time parsing filenames before passing them as parameters.

Cheers
The GuyGui

Gintas

  • Jr. Member
  • **
  • Posts: 71
    • Developer's Diary
Re: SOLVED: Linux: Copyfile Problems
« Reply #3 on: April 27, 2011, 08:15:35 pm »
I wonder how about CopyFile function in WUtils unit? Does it have some bugs?

 

TinyPortal © 2005-2018