Re: how copy file on linux?

Liste des GroupesRevenir à l c 
Sujet : Re: how copy file on linux?
De : lew.pitcher (at) *nospam* digitalfreehold.ca (Lew Pitcher)
Groupes : comp.lang.c
Suivi-à : comp.unix.programmer
Date : 27. Jun 2024, 01:24:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v5i7vu$28id7$1@dont-email.me>
References : 1 2
User-Agent : Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2)
(Followup set to comp.unix.programmer)

On Wed, 26 Jun 2024 15:35:00 -0700, Keith Thompson wrote:

Thiago Adams <thiago.adams@gmail.com> writes:
How to copy a file on linux keeping the original file information?
timestamp etc?
>
Or in other words the equivalent of CopyFileA from windows.
 
comp.unix.programmer is likely to give you better answers.  I don't
think POSIX defines any functions that copy files.

No, AFAIK, POSIX doesn't define an "all-in-one" file copy function.
However, Linux (the OS Thiago asks about) defines a number of them.

If I uunderstand correctly, you want to do the equivalent of "cp -p",

Which /can/ be accomplished with POSIX calls
  - the standard I/O functions (fopen()/open(), fread()/read(),
    fwrite()/write(), fclose()/close() ) to copy the file data
  - stat() to obtain the "original file information", and
  - utime() to set the copy timestamps,
  - chmod() to set the copy file permissions
  - chown() to set the file ownership

But, perhaps Thiago would be satisfied with just a hardlinked file.

but from C rather than from a shell.  You might consider using system(),
but that has some drawbacks, and there are probably better ways.


HTH
--
Lew Pitcher
"In Skills We Trust"

Date Sujet#  Auteur
26 Jun 24 * how copy file on linux?10Thiago Adams
26 Jun 24 +- Re: how copy file on linux?1Janis Papanagnou
27 Jun 24 +* Re: how copy file on linux?2Keith Thompson
27 Jun 24 i`- Re: how copy file on linux?1Lew Pitcher
27 Jun 24 +* Re: how copy file on linux?2Lawrence D'Oliveiro
28 Jun 24 i`- Re: how copy file on linux?1Bonita Montero
28 Jun 24 `* Re: how copy file on linux?4Bonita Montero
29 Jun 24  `* Re: how copy file on linux?3Malcolm McLean
29 Jun 24   `* Re: how copy file on linux?2Lew Pitcher
29 Jun 24    `- Re: how copy file on linux?1Lew Pitcher

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal