| Deutsch English Français Italiano |
|
<v5icd7$2d3iu$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thiago Adams <thiago.adams@gmail.com> Newsgroups: comp.unix.programmer Subject: Re: how copy file on linux? Date: Wed, 26 Jun 2024 21:40:06 -0300 Organization: A noiseless patient Spider Lines: 43 Message-ID: <v5icd7$2d3iu$1@dont-email.me> References: <v5huk1$2anbd$1@dont-email.me> <87v81vs57v.fsf@nosuchdomain.example.com> <v5i7vu$28id7$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 27 Jun 2024 02:40:07 +0200 (CEST) Injection-Info: dont-email.me; posting-host="95346367adb7016ac45f84428f65517e"; logging-data="2526814"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+OWrhKWrxWEtlPUl8bKX7yXcZZte+xVn4=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:sK6B6Rt9oizh8teQYeNKmLV9S0o= In-Reply-To: <v5i7vu$28id7$1@dont-email.me> Content-Language: en-GB Bytes: 2812 Em 6/26/2024 8:24 PM, Lew Pitcher escreveu: > (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. > > I am using this to create a "deploy" folder with all files necessary to run a program. So on windows I am coping dlls and I think it is a good idea to keep the original file attributes . (I am not sure if zip files keep that.. I need to check) On linux I may need to copy some files and I think is is a good idea to keep the original attributes as well.