amstream.h
来自「JPEG解压软件,包含PC端的测试程序,程序结构比较清晰」· C头文件 代码 · 共 324 行
H
324 行
/*
* AMStream.h
*
*
*/
#ifndef _AMSTREAM_H
#define _AMSTREAM_H
#include "AMComDef.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef MVoid* HMSTREAM;
#define INVALID_HMSTREAM MNull
#define STREAM_BEGIN 0
#define STREAM_END 1
#define STREAM_CUR 2
#define STREAM_READ 0x0001
#define STREAM_WRITE 0x0002
#define STREAM_APPEND 0x0004
#define STREAM_R_PLUS 0x0008
#define STREAM_W_PLUS 0x0010
#define STREAM_A_PLUS 0x0020
/////////////////////Stream open and close functions///////////////////////
/**
* AMStreamOpenFromFile
* open a stream from file
*
* Parameter:
* path (in) the path of file , it can be null
* name (in) the name of file
* mode (in) file read and write mode
*
* Return:
* returns the HMSTREAM handle if successful , INVALID_HMSTREAM if failed.
*
* Remark:
*
*/
HMSTREAM AMStreamOpenFromFile(MPCChar path, MPCChar name,MWord mode);
/**
* AMStreamOpenFromMem
* open a stream from memory
*
*
* Parameter:
* mem (in) the point to a allocated memory block
* mem_size (in) the size of memory block
*
* Return:
* returns the HMSTREAM handle if successful , INVALID_HMSTREAM if failed.
*
* Remark:
*
*/
HMSTREAM AMStreamOpenFromMem(void* mem,MLong mem_size);
/**
* AMStreamClose
* close a stream
*
* Parameter:
* stream_handle (in) the handle of HMSTREAM
*
* Return:
* returns MTrue if successful , MFalse if failed.
*
* Remark:
*
*/
MBool AMStreamClose(HMSTREAM stream_handle);
//////////////////////the functions only for file stream//////////////////////
/**
* AMStreamFileGetName
* Get file name from a file stream
*
* Parameter:
* stream_handle (in) the handle of HMSTREAM
*
* Return:
* returns the name of file
*
* Remark:
*
*/
MPCChar AMStreamFileGetName(HMSTREAM stream_handle);
/**
* AMStreamFileGetPath
* Get file path from a file stream
*
* Parameter:
* stream_handle (in) the handle of HMSTREAM
*
* Return:
* returns the path of file
*
* Remark:
*
*/
MPCChar AMStreamFileGetPath(HMSTREAM stream_handle);
/**
* AMStreamIsFileExist
* Check the file exist
*
* Parameter:
* file (in) the path of file
* file (in) the name of file
*
* Return:
* returns MTure if file exist ,otherwise return MFalse
*
* Remark:
*
*/
MBool AMStreamIsFileExist(MPCChar path, MPCChar name);
/**
* AMStreamFileCreate
* create a file stream
*
* Parameter:
* path (in) the path of file
* name (in) the name of file
*
* Return:
* returns the HMSTREAM handle if successful , INVALID_HMSTREAM if failed.
*
* Remark:
*
*/
HMSTREAM AMStreamFileCreate(MPCChar path, MPCChar name);
/**
* AMStreamFileDestroy
* destory a file
*
* Parameter:
*
* path (in) the path of file
* name (in) the name of file
*
* Return:
* returns MTure if destory success ,otherwise return MFalse.
*
* Remark:
*
*/
MBool AMStreamFileDestroy(MPCChar path, MPCChar name);
/**
* AMStreamFileDestroy
* rename a file
*
* Parameter:
*
* old_path (in) the old path
* old_name (in) the old name
* new_path (in) the new path
* new_name (in) the new name
*
* Return:
* returns MTure if destory success ,otherwise return MFalse.
*
* Remark:
*
*/
MBool AMStreamFileRename(MPCChar old_file_path, MPCChar old_file_name,MPCChar new_file_path, MPCChar new_file_name);
/**
* AMStreamFileGetSize
* get size from a file.
*
* Parameter:
*
* path (in) the path of file
* name (in) the name of file
*
* Return:
* returns file size
*
* Remark:
*
*/
MLong AMStreamFileGetSize(MPCChar file_path, MPCChar file_name);
////////////////////////the functions for both file and memory stream/////////////////////////////
/**
* AMStreamGetSize
* get total size from a stream.
*
* Parameter:
*
* stream_handle (in) the handle of HMSTREAM
*
* Return:
* returns the stream size
*
* Remark:
*
*/
MLong AMStreamGetSize(HMSTREAM stream_handle);
/**
* AMStreamRead
* reads data from a stream.
*
* Parameter:
*
* stream_handle (in) the handle of HMSTREAM
* buf (in) the buf to read in
* size (in) the size of buf
*
* Return:
* returns the number of full items actually read,
*
* Remark:
*
*/
MLong AMStreamRead(HMSTREAM stream_handle,void* buf,MLong size);
/**
* AMStreamWrite
* writes data to a stream.
*
* Parameter:
*
* stream_handle (in) the handle of HMSTREAM
* buf (in) pointer to data to be written
* size (in) the size of buf
*
* Return:
* returns the number of full items actually written,
*
* Remark:
*
*/
MLong AMStreamWrite(HMSTREAM stream_handle,void* buf,MLong size);
/**
* AMStreamFlush
* flushes a stream
*
* Parameter:
*
* stream_handle (in) the handle of HMSTREAM
*
* Return:
* if the stream was successfully flushed,return MTure
* Otherwise, returns MFalse
*
* Remark:
*
*/
MBool AMStreamFlush(HMSTREAM stream_handle);
/**
* AMStreamSeek
* Moves the stream pointer to a specified location
*
* Parameter:
*
* stream_handle (in) the handle of HMSTREAM
* start (in) Initial position
* offset (in) Number of bytes from start
*
* Return:
* If successful, stream_seek returns 0
* Otherwise, returns a nonzero value
*
* Remark:
*
*/
MLong AMStreamSeek(HMSTREAM stream_handle,MShort start, MLong offset);
/**
* AMStreamTell
* Get the current position of a stream pointer
*
* Parameter:
*
* stream_handle (in) the handle of HMSTREAM
*
* Return:
* returns the current stream position, -1 if failed.
*
* Remark:
*
*/
MLong AMStreamTell(HMSTREAM stream_handle);
#ifdef __cplusplus
}
#endif
#endif /*_AMSTREAM_H*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?