📄 fileopr.h
字号:
/********************************************************************** FileName : FileOpr.h Description : 文件操作类头文件 Version : 1.0 Date : 2003年6月17日 Author : 刘荣辉 Other : 一个对象不能同时操作多个文件***********************************************************************///#if !defined(AFX_FILEOPR_H__1A0B7FCC_EA3E_4A1F_808C_ABF9018551A4__INCLUDED_)//#define AFX_FILEOPR_H__1A0B7FCC_EA3E_4A1F_808C_ABF9018551A4__INCLUDED_//#if _MSC_VER > 1000//#pragma once//#endif // _MSC_VER > 1000#ifndef __FILEOPR_H__#define __FILEOPR_H__#include <stdio.h>#include <memory.h>#include <string.h>#include <time.h>#include <iostream.h>#include <fstream.h>#include <signal.h>#include <unistd.h>#include <netinet/in.h> //ntohl#include <mysql.h> //mysql_escape_string#include "sys_struct.h"using namespace std;#define BGNMSG "#"#define ENDMSG ""#define MAXBUF 1024#define MAXARRAY 200#define MAXBYTE 2400 //待备份包的最大长度class FileOpr{public: FileOpr(); virtual ~FileOpr(); //写上端CMPP_Deliver接收日志文件 int WrCMPP_DeliverLog(Cmpp_Deliver_Log *pDeliverLog, char* strBuf); //写上端CMPP_Report接收日志文件 int WrCMPP_ReportLog(Cmpp_Deliver_Log *pReportLog, char* strBuf); //写下端CMPP_Submit接收日志文件 int WrCMPP_SubmitLog(Cmpp_Submit_Log *pSubmitLog, char* strBuf); //写上端SMGP_Deliver接收日志文件 int WrSMGP_DeliverLog(Smgp_Deliver_Log *pParam, char* strBuf); //写上端SMGP_Report接收日志文件 int WrSMGP_ReportLog(Smgp_Deliver_Log *pParam, char* strBuf); int RecvQ_Backup(RecvQUnit *RUnit); int SendQ_Backup(SendQUnit *SUnit); RecvQUnit * RecvQ_Restore(char *FileName, int *GotNum); SendQUnit * SendQ_Restore(char *FileName, int *GotNum); int RWRead(char *szBuf,int *pInt); //从配置文件中读取一个整数 int RWRead(char *szBuf,char *szRst); //从配置文件中读取一个字符串 //打开一个文件(含路径),szMode:"r"=>只读打开,"ow"=>覆盖写打开,"w"=>追加写打开,且自动在文件名后加日期 int RWOpen(char* szFileName,char *szMode); int RWClose(); //关闭文件 int WriteLog(void *pParam, const int iType); //写文件的外部接口函数 int getDate(char* szDate); //获取系统日期("yymmdd") char* getTime(char* buf); //获取系统时间"yymmddhhmmss"private: int ReadLine(); //从文件中一行行读取全部内容 int CreateFile(char* szBuf);//关闭旧文件,创建并打开新文件 int NewDateFile(); //若为新的一天,则创建并打开一个新文件 FILE* fp; char RWFileName[100]; char FileForeName[100]; ifstream inFile; //read stream of the file ofstream outFile; //write stream of the file long CurrentDate; //当前文件后缀的日期 bool m_bRead; //the read flag of the opened file char m_szReadBuf[MAXARRAY][MAXBUF]; unsigned int m_nCount; //文件中的行数 sem_t SemMutex; //防止多个线程同时写一个文件的信号量,用于互斥};#endif // !defined(AFX_FILEOPR_H__1A0B7FCC_EA3E_4A1F_808C_ABF9018551A4__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -