Changeset 3851677 in tol


Ignore:
Timestamp:
Oct 26, 2008, 7:16:38 PM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
997c16c
Parents:
b6e52e72
Message:

New method Cat

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@94 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol/bbasic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tol/bbasic/sys.cpp

    rb6e52e72 r3851677  
    591591}
    592592
     593//--------------------------------------------------------------------
     594BBool BSys::Cat(const BArray<BText>& origin, const BText& target)
     595
     596/*! Cats a set of files into target.
     597 * \return Returns true on success, or false if an error occurred
     598 */
     599//--------------------------------------------------------------------
     600{
     601  static const int bufferSize_ = 1024*1024;
     602  static char buffer_[bufferSize_];
     603  FILE* in;
     604  FILE* out = fopen(target.String(),"wb");
     605  if(!out)
     606  {
     607    Error(I2("Cannot open for write file ",
     608             "No se pudo abrir para escritura el fichero ")+
     609          target);
     610    return(false);
     611  }
     612  int i, numBytes, size, pos;
     613  for(i=0; i<origin.Size(); i++)
     614  {
     615    size = GetFileSize(origin[i]);
     616    in = fopen(origin[i].String(),"rb");
     617    if(!in)
     618    {
     619      Error(I2("Cannot open for read file ",
     620               "No se pudo abrir para lectura el fichero ")+
     621            origin[i]);
     622      return(false);
     623    }
     624    pos = 0;
     625    while(pos<size)
     626    {
     627      numBytes = bufferSize_;
     628      if(numBytes>size-pos) { numBytes = size-pos; }
     629      fread (&buffer_,1,numBytes,in);
     630      fwrite(&buffer_,1,numBytes,out);
     631      pos += numBytes;
     632    }
     633    fclose(in);
     634  }
     635  fclose(out);
     636  return(true);
     637}
    593638
    594639//--------------------------------------------------------------------
  • tol/bbasic/tol_bsys.h

    rb6e52e72 r3851677  
    117117                            bool  wait=BFALSE);
    118118#endif
    119   static BBool  ChildProcess(const BText& command);
     119  static BBool ChildProcess(const BText& command);
    120120  //! Prints a file in the default printer.
    121   static BBool  Print      (const BText& fileName);
     121  static BBool Print(const BText& fileName);
    122122  //! Removes a file
    123   static BBool  Remove     (const BText& fileName);
     123  static BBool Remove(const BText& fileName);
    124124  //! Copies \a origin file(s) to \a target
    125   static BBool  Copy       (const BText& origin, const BText& target);
     125  static BBool Copy(const BText& origin, const BText& target);
     126  static BBool Cat(const BArray<BText>& origin, const BText& target);
     127
    126128  //! Prints a file in the default printer and removes this file from disk.
    127129  static BBool  PrintUnlink(const BText& fileName);
Note: See TracChangeset for help on using the changeset viewer.