www.pudn.com > NETINFO.rar > tools.h


#ifndef _TOOLS_H_ 
#define _TOOLS_H_ 
 
//write buffer of length to filename 
BOOL WriteBufferToFile(const char* fileName, void*buffer, DWORD length); 
 
//return true if file remained 
//else return false 
BOOL DeleteEmptyFile(const char* filename); 
 
//print a binary buffer with length = count in hexical number, 
//which a line can hold at most countPerLine byte 
void PrintHexByte(FILE* fp, const BYTE* buf, DWORD count, DWORD countPerLine); 
 
//print a binary buffer with nonprintable char printed as '.' 
void PrintTxtByte(FILE*fp, const BYTE* buf, DWORD count, DWORD countPerLine); 
 
//get digest of a buffer using XOR method 
DWORD GetDigest(const BYTE*pData, DWORD length); 
 
//convert unix file name to dos file name 
void UnixPath2DosPath(const char unixFileName[], char dosFileName[]); 
 
//precreate path for creating a file 
void CreateFilePath(const char fileName[MAX_PATH]); 
 
//get dir part from a filename, and dir part include end char '\\' or '/' or ':' 
void GetFilePath(const char filename[MAX_PATH], char fileDir[MAX_PATH]); 
 
BOOL ExistFileOrDirectory(const char filename[MAX_PATH]); 
 
BOOL ExistFile(const char filename[MAX_PATH]); 
 
BOOL ExistDirectory(const char filename[MAX_PATH]); 
 
void GetTempFullFileName(char filepath[MAX_PATH]); 
 
BOOL GetFileLength(const char filename[MAX_PATH], DWORD*pFileLength); 
 
 
#define GET_UPPER_CHAR(c) ( ('a'<=(c)&&(c)<='z') ? (c)-'a'+'A' : (c) ) 
 
//if string include begin at the begin, return TRUE, else return FALSE 
BOOL BeginWith(const char*string, const char*begin, BOOL bCaseSensitive = FALSE); 
 
BOOL GetExtFromMimeType(const char type[], const char subType[], char ext[MAX_PATH]); 
 
void GetPureFileName(const char szFilepath[], char szFilename[]); 
 
#endif