Re: cross-platform library for file system operations

new topic     » topic index » view thread      » older message » newer message

Hello jbrown,

you wrote:
<snip>

> Excellent.

Thanks. smile

> I recommend also adding copy_file() (which can be done in pure Eu,
> fortuantly, as there seems to be no function call for this under
> Linux),

There also seems to be no function call for this under DOS.
I already took a copy function into consideration, too. But at least
under DOS, there are some obstacles that we have to get around:

a) I would want copy_file() not only to copy the contents of a file,
   but also the time stamp and (at least under DOS/Windows) the
   attributes. Just to be able to get and set the time stamp of a file
   under DOS, yesterday I changed 2 existing low-level functions and
   added 4 others! They seem to work now, but I want to look at them
   again and do some more testing.
   Then, we will need a method to "copy" the time stamp of a file under
   Linux, too.

b) And what about the time stamps of directories? When I copy a
   directory under Windows with my favourite file manager, the new one
   doesn't inherit it's time from the original, but is stamped with the
   current time. If this is the same under DOS and Linux, this will
   make things easier for us. To say the truth, at the moment I don't
   know any way of changing the time stamp of a directory under old DOS
   with short filenames.

c) The Euphoria documentation says, that Eu can't create a new file with
   a _long_ filename under DOS. Of course, this feature is needed for
   copying under DOS. But as a workaround, I could create a file with a
   short name and then rename() it.

d) IMO a really good copy function will look at the target drive, if
   there is enough free space, before it starts copying.
   If I remember right, this is hard to do under DOS with this huge
   Gigabyte drives, that we have nowadays.

After all, at the moment, I'm rather confident that we will be able to
make a good copy_file() function. smile


> copy_dir() (which should be recursive)

Very good idea!

> and move() (which could work by
> calling copy_file/dir() and then del_file/dir(),

Yes, I would like move() to work something like this:

   function move(source, target)
      if on_the_same_disk(source, target) then
         i = rename(source, target)     -- file or dir doesn't matter
      elsif is_file(source) then        -- to decide, whether a given
         i = copy_file(source, target)  --   "disk object" is a file or
         if i != -1 then                --   dir, under DOS/Win one must
            i = del_file(source)        --   use the attribute
         end if
      else
         i = copy_dir(source, target)
         if i != -1 then
            i = del_dir(source)
         end if
      end if
      return i
   end function

   
> I can not seem to find
> a version of this function under Linux either.)

> I have added a sample (and untested!) copy_file() function for your
> review.

Well, thank you. This of course will be the "heart" of copy_file().

<snip>
> That is completely acceptable to me. btw Linux will return -1 on error,
> but also sets up a variabl called ERRNO which tells which error
> occurred.

Very good idea! But this could mean a lot of additional work...
Maybe for the beginning, we should concentrate on the, let's say,
10 most common errors, and any other error will result in a message like
"<platform> error <errno>" or so. If we have a good framework, it will
be easy to add specific error numbers and messages later on.

> Perhaps a similar method (but easier to understand :) could be used
> for this lib.

In my opinion, it should be up to the user, if in a given situation
she/he wants to get an error _number_, or a human understandable
_message_. So our lib should provide both possibilities. The error
messages should be in a separate include file for easy translation.
When I have some more time, I will have a look on some other projects,
to see how they handle errors.
I just began to write an error handling "framework". As soon as possible,
I will show it to you, then waiting for your judgement...

[directory names with or without trailing slashes]
> For the Linux functions, it doesnt matter either, so I have to write no
> extra code to handle this.

Very nice!

<snip>
> I have one question is regard to get/set_attr() - Linux has a
> completely different way of using file attributes.

sad(

> Do you wish for me to attempt to emulate partial support for the
> DOS attributes (Linux does not support full emulation of this)
> or do you just want me to create a set of Linux constants and a
> Linux version of get/set_attr()? I am not sure what you would want
> me to do, so I ask for your opinion.

At the moment, I can't answer this question. Could you please give me
some examples, so that I have an idea of what the Linux attributes are
and what they do?

> I have attached the file file2.e to this email, Juergen you may put
> this file in your file2.zip on your web site.

Done.
But nothing new for you inside there, at the moment.

> jbrown

Best regards,
   Juergen

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu