Advertisement
FlyFar

velasco_file.cpp

Mar 9th, 2023
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | Cybersecurity | 0 0
  1. // Arquivo obtido em:
  2. // http://www.todosymbian.com/files2/file.zip
  3.  
  4. #include "file.h"
  5.  
  6.  
  7. bool File::Open(const TDesC &name,unsigned int mode){
  8.     TInt mask = 0;
  9.     TInt err = 0;
  10.  
  11.     fsSession.Connect();
  12.  
  13.     if(mode&OMText) mask = EFileStreamText;
  14.     if(mode&OMRead) mask |= EFileRead;
  15.     if(mode&OMWrite) mask |= EFileWrite;
  16.  
  17.     if(mode&OMCreate) err =  rFile.Create(fsSession,name,mask);
  18.     else if(mode&OMReplace) err =  rFile.Replace(fsSession,name,mask);
  19.     else if(mode&OMOpen) err = rFile.Open(fsSession,name,mask);
  20.  
  21.     if(err != KErrNone){
  22.         fsSession.Close();
  23.         return false;
  24.     }else
  25.         return true;
  26. }
  27.  
  28.  
  29. void File::Close(){
  30.     rFile.Flush();
  31.     rFile.Close();
  32.     fsSession.Close();
  33. }
  34.  
  35.  
  36. int File::Read(void *buff,int length){
  37.     TPtr8 ptr((unsigned char*)buff,length);
  38.     rFile.Read(ptr,length);
  39.     return ptr.Length();
  40. }
  41.  
  42.  
  43. int File::Write(void *buff,int length){
  44.     TPtr8 ptr((unsigned char*)buff,length,length);
  45.     rFile.Write(ptr);
  46.     return ptr.Length();
  47. }
  48.  
  49.  
  50. void File::Seek(TSeek mode,int offSet){
  51.     rFile.Seek(mode,offSet);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement