Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FileWrapper.h 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. **
  3. ** Copyright (C) 2011 Opera Software ASA. All rights reserved.
  4. **
  5. ** This file is part of the Opera web browser.
  6. ** It may not be distributed under any circumstances.
  7. */
  8. #ifndef FILEWRAPPER_H
  9. #define FILEWRAPPER_H
  10. #include "modules/pi/system/OpLowLevelFile.h"
  11. /** Pass-through wrapper class for OpLowLevelFile's.
  12. *
  13. * This class can be wrapped around any OpLowLevelFile to perform... nothing.
  14. * It works as a parent class for implementations that do... something.
  15. */
  16. class FileWrapper
  17. : public OpLowLevelFile
  18. {
  19. public:
  20. /** Create a FileWrapper.
  21. *
  22. * This does not create or open the file (but the supplied wrapped_file
  23. * may be already created or open).
  24. *
  25. * @param wrapped_file The normal OpLowLevelFile that will handle actual I/O.
  26. * @param transfer_ownership If TRUE, the ownership of wrapped_file
  27. * is transferred to the new FileWrapper, which becomes responsible for
  28. * deallocating it in the destructor. In this case the wrapped_file object must have
  29. * been allocated using OP_NEW.
  30. */
  31. FileWrapper(OpLowLevelFile* wrapped_file, BOOL transfer_ownership);
  32. ~FileWrapper();
  33. const uni_char* GetFullPath() const;
  34. const uni_char* GetSerializedName() const;
  35. OP_STATUS GetLocalizedPath(OpString *localized_path) const;
  36. BOOL IsWritable() const;
  37. OP_STATUS Open(int mode);
  38. BOOL IsOpen() const;
  39. BOOL Eof() const;
  40. OP_STATUS Write(const void* data, OpFileLength len);
  41. OP_STATUS Read(void* data,
  42. OpFileLength len,
  43. OpFileLength* bytes_read);
  44. OP_STATUS ReadLine(char** data);
  45. OpLowLevelFile* CreateCopy();
  46. OpLowLevelFile* CreateTempFile(const uni_char* prefix);
  47. OP_STATUS CopyContents(const OpLowLevelFile* copy);
  48. OP_STATUS SafeClose();
  49. OP_STATUS SafeReplace(OpLowLevelFile* new_file);
  50. OP_STATUS Exists(BOOL* exists) const;
  51. OP_STATUS GetFilePos(OpFileLength* pos) const;
  52. OP_STATUS GetFileLength(OpFileLength* len) const;
  53. OP_STATUS GetFileInfo(OpFileInfo* info);
  54. #ifdef SUPPORT_OPFILEINFO_CHANGE
  55. OP_STATUS ChangeFileInfo(const OpFileInfoChange* changes);
  56. #endif
  57. OP_STATUS Close();
  58. OP_STATUS MakeDirectory();
  59. OP_STATUS Delete();
  60. OP_STATUS Flush();
  61. OP_STATUS SetFilePos(OpFileLength pos,
  62. OpSeekMode mode = SEEK_FROM_START);
  63. OP_STATUS SetFileLength(OpFileLength len);
  64. #ifdef PI_ASYNC_FILE_OP
  65. void SetListener(OpLowLevelFileListener* listener);
  66. OP_STATUS ReadAsync(void* data,
  67. OpFileLength len,
  68. OpFileLength abs_pos = FILE_LENGTH_NONE);
  69. OP_STATUS WriteAsync(const void* data,
  70. OpFileLength len,
  71. OpFileLength abs_pos = FILE_LENGTH_NONE);
  72. OP_STATUS DeleteAsync();
  73. OP_STATUS FlushAsync();
  74. OP_STATUS Sync();
  75. BOOL IsAsyncInProgress();
  76. #endif // PI_ASYNC_FILE_OP
  77. private:
  78. FileWrapper();
  79. protected:
  80. OpLowLevelFile* m_f;
  81. const BOOL m_owns_file;
  82. int m_mode;
  83. };
  84. #endif // !FILEWRAPPER_H