1 Star 0 Fork 0

wangzhankun/untrunc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
file.h 1.90 KB
一键复制 编辑 原始数据 按行查看 历史
ponchio 提交于 5年前 . logging added
//==================================================================//
/*
Untrunc - file.h
Untrunc is GPL software; you can freely distribute,
redistribute, modify & use under the terms of the GNU General
Public License; either version 2 or its successor.
Untrunc is distributed under the GPL "AS IS", without
any warranty; without the implied warranty of merchantability
or fitness for either an expressed or implied particular purpose.
Please see the included GNU General Public License (GPL) for
your rights and further details; see the file COPYING. If you
cannot, write to the Free Software Foundation, 59 Temple Place
Suite 330, Boston, MA 02111-1307, USA. Or www.fsf.org
Copyright 2010 Federico Ponchio
*/
//==================================================================//
#ifndef FILE_H
#define FILE_H
#include <vector>
#include <string>
extern "C" {
#include <stdint.h>
}
#include <cstdio>
// Swap the 8-bit bytes into their reverse order.
uint16_t swap16(uint16_t us);
uint32_t swap32(uint32_t ui);
uint64_t swap64(uint64_t ull);
// Encapsulate FILE (RAII).
class File {
public:
File();
~File();
bool open (std::string filename);
bool create(std::string filename);
operator bool() { return static_cast<bool>(file); }
off_t pos();
void seek(off_t offset);
void rewind();
bool atEnd();
off_t size();
off_t length() { return size(); }
int32_t readInt();
uint32_t readUInt();
int64_t readInt64();
void readChar(char *dest, size_t n);
std::vector<unsigned char> read(size_t n);
ssize_t writeInt (int32_t value);
ssize_t writeInt64(int64_t value);
ssize_t writeChar (const char *source, size_t n);
ssize_t write(std::vector<unsigned char> &v);
protected:
std::FILE *file;
off_t file_sz;
void close();
private:
// Disable copying.
File(const File&);
File& operator=(const File&);
};
#endif // FILE_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangzhankun/untrunc.git
git@gitee.com:wangzhankun/untrunc.git
wangzhankun
untrunc
untrunc
master

搜索帮助