Re: how copy file on linux?

Liste des GroupesRevenir à cl c  
Sujet : Re: how copy file on linux?
De : malcolm.arthur.mclean (at) *nospam* gmail.com (Malcolm McLean)
Groupes : comp.lang.c
Date : 29. Jun 2024, 01:04:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v5nfh0$3i4n8$1@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 28/06/2024 19:15, Bonita Montero wrote:
int fromFile = open( from, O_RDONLY | O_NOATIME );
     if( !fromFile )
         return false;
     invoke_on_destruct closeFrom( [&] { close( fromFile ); } );
 //    int toFile = open( to, O_CREAT );
 //    if( !toFile )
 //        return false;
     invoke_on_destruct closeTo( [&] { close( toFile ); } );
//     invoke_on_destruct delTo( [&] { unlink( to ); } );
     for( int64_t remaining = attrFrom.st_size; remaining > 0; remaining -= 0x100000 )
     {
         size_t n = (size_t)(remaining >= 0x100000 ? 0x100000 : remaining);
         buf.resize( n );
         if( read( fromFile, buf.data(), n ) )
         {
             // this branch is taken
             cout << strerror( errno ) << endl;
             return false;
         }
So it claims the file opens, then won't read it?
Check the call. Is 0 the success return?
Then I must admit I'm stumped. "to" doesn't alias "from" I suppose?
I'd also wonder if somehow the C++ compiler has invoked the on destruct code, and closed the file.
--
Check out my hobby project.
http://malcolmmclean.github.io/babyxrc

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