1 /* 2 * MtpFile.h 3 * 4 * Author: Jason Ferrara 5 * 6 * This software is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * version 3 as published by the Free Software Foundation. 9 * 10 * This software is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02111-1301, USA. 19 * licensing@fsf.org 20 */ 21 22 #ifndef MTPFILE_H_ 23 #define MTPFILE_H_ 24 25 #include "MtpNode.h" 26 #include <stdio.h> 27 28 class MtpFile : public MtpNode 29 { 30 public: 31 MtpFile(MtpDevice& device, MtpMetadataCache& cache, uint32_t id); 32 ~MtpFile(); 33 34 std::unique_ptr<MtpNode> getNode(const FilesystemPath& path); 35 void getattr(struct stat& info); 36 37 void Open(); 38 void Close(); 39 int Read(char *buf, size_t size, off_t offset); 40 int Write(const char* buf, size_t size, off_t offset); 41 void Remove(); 42 43 void Fsync(); 44 void Truncate(off_t length); 45 void Rename(MtpNode& newParent, const std::string& newName); 46 47 MtpNodeMetadata getMetadata(); 48 49 protected: 50 MtpFileInfo m_info; 51 bool m_opened; 52 FILE* m_localFile; 53 bool m_needWrite; 54 }; 55 56 57 58 #endif /* MTPFILE_H_ */ 59