Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-06

File-functions on various platforms??

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Thomas Zastrow

Hello,

for a little FPC-/Lazarus-project I need some routines working on the filesystem - for example: "Give me (recursivly) all *mp3-Files in this directory".

Searching around in the online-documenation, I found that FPC knows functions like FindFirst, FindNext and so on.

My question is: Are these function are working both on Linux and on Windows??? Using an OpenFileDialog in Lazarus and take it's property "filename" for input/output of these functions, will it work both on Windows and Linux??? Are there any functions for converting Windows-Path's to Unix-Path's???

Thanks,

Tom

Reply by email

Michael Van Canneyt
to Thomas Zastrow
Thomas Zastrow wrote 10 lines
Hello, for a little FPC-/Lazarus-project I need some routines working on the filesystem - for example: "Give me (recursivly) all *mp3-Files in this directory". Searching around in the online-documenation, I found that FPC knows functions like FindFirst, FindNext and so on. My question is: Are these function are working both on Linux and on Windows???

Yes.

Using an OpenFileDialog in Lazarus and take it's property "filename" for input/output of these functions, will it work both on Windows and Linux???

Yes.

Are there any functions for converting Windows-Path's to Unix-Path's???

Yes, in sysutils:

Procedure DoDirSeparators (Var FileName : String);
Function SetDirSeparators (Const FileName : String) : String;

And if you use the PathDelim constant consistently, then there should be no need to use these functions, even.

Michael.

Reply by email

Thomas Zastrow
to Michael Van Canneyt
Michael Van Canneyt wrote 45 lines
On Fri, 10 Jun 2005, Thomas Zastrow wrote: >Hello, > >for a little FPC-/Lazarus-project I need some routines working on the >filesystem - for example: "Give me (recursivly) all *mp3-Files in this >directory". > >Searching around in the online-documenation, I found that FPC knows functions >like FindFirst, FindNext and so on. > >My question is: Are these function are working both on Linux and on Windows??? > > Yes. >Using an OpenFileDialog in Lazarus and take it's property "filename" for >input/output of these functions, will it work both on Windows and Linux??? > > Yes. >Are there any functions for converting Windows-Path's to Unix-Path's??? > > Yes, in sysutils: Procedure DoDirSeparators (Var FileName : String); Function SetDirSeparators (Const FileName : String) : String; And if you use the PathDelim constant consistently, then there should be no need to use these functions, even. Michael.

Michael, thank you very much :-)

At the moment, I'm converting a lot of my old Delphi-Code to Lazarus / FPC. I'm working on a project which should run on windows *and* on Linux .. the most difficulties I have is when it comes up to deal with File-Paths.

The most of my old procedures and functions are running fine with Lazarus under Windows - but not under Linux, because they have something like the "\" hardcoded for dividing directories.

I'm realy not sure how to handle this ... perhaps somebody has some procedures, dealing with pathes, directories and so on ... and using *no* platform-specific-code???

Greetings,

Tom

Reply by email

Michael Van Canneyt
to Thomas Zastrow
Thomas Zastrow wrote 19 lines
> no need to use these functions, even. > > Michael. > > Michael, thank you very much :-) At the moment, I'm converting a lot of my old Delphi-Code to Lazarus / FPC. I'm working on a project which should run on windows *and* on Linux .. the most difficulties I have is when it comes up to deal with File-Paths. The most of my old procedures and functions are running fine with Lazarus under Windows - but not under Linux, because they have something like the "\" hardcoded for dividing directories. I'm realy not sure how to handle this ... perhaps somebody has some procedures, dealing with pathes, directories and so on ... and using *no* platform-specific-code???

Check the sysutils unit. It's your best bet. It contains a number of calls to deal with must situations; I don't think I ever needed a function for treating files which wasn't in sysutils. But maybe my needs are limited :)

Michael.

Reply by email