Lfs ---> LfsClientLocalImp
来源:互联网 发布:橙光文字游戏制作软件 编辑:程序博客网 时间:2024/06/06 03:16
#ifndef LFS_CLIENT_LOCAL_IMP_H
#define LFS_CLIENT_LOCAL_IMPH
#include "CommonDefine.h"
namespace lfs {
class LfsClientLocalImp
{
public:
int Initialize(const char* nsAddr = NULL);
int Close(const int fd);
int Open(const char* fileName, const int flags);
int Write(const int fd, const void* data, int64_t count);
int Read(const int fd, void* buf, const int64_t count);
int Unlink(const char* fileName);
int Fstat(const int fd, common::FileInfo& buf);
int64_t SaveFile(char* fileName, const char* localFile, const int32_t flag, const char* nsAddr = NULL);
int FetchFile(const char* localFile, const char* fileName, const char* nsAddr = NULL);
};
} // Namespace lfs
#endif
#include "LfsClientLocalImp.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "Log.h"
namespace lfs{
int LfsClientLocalImp::Initialize(const char* nsAddr)
{
LOG_INFO("Initialized");
// Global Namespace Init --> Maybe read from Config file
return 0;
}
int LfsClientLocalImp::Close(const int fd)
{
if(fd < 0)
{
LOG_ERROR("fd error!");
return -1;
}
return ::close(fd);
}
int LfsClientLocalImp::Open(const char* fileName, const int flags)
{
if(fileName == NULL)
{
LOG_ERROR("file Name NULL");
return -1;
}
return ::open(fileName, flags);
}
int LfsClientLocalImp::Write(const int fd, const void* data, int64_t count)
{
if(fd < 0 || data == NULL || count < 0)
{
LOG_ERROR("fd error or data NULL or count < 0!");
return -1;
}
return ::write(fd, data, count);
}
int LfsClientLocalImp::Read(const int fd, void* buf, const int64_t count)
{
if(fd < 0 || buf == NULL || count < 0)
{
LOG_ERROR("fd error or data NULL or count < 0!");
return -1;
}
return ::read(fd, buf, count);
}
int LfsClientLocalImp::Unlink(const char* fileName)
{
if(fileName == NULL)
{
LOG_ERROR("fileName NULL");
return -1;
}
return unlink(fileName);
}
int LfsClientLocalImp::Fstat(const int fd, common::FileInfo& buf)
{
struct stat fst;
int ret = ::fstat(fd, &fst);
if(ret != 0 )
{
LOG_ERROR("get the file info error from OS!");
return -1;
}
buf.ID = fst.st_ino;
buf.Size = fst.st_size;
buf.UsedSize = fst.st_blksize * fst.st_blocks;
buf.ModifyTime = fst.st_mtime;
buf.CreateTime = fst.st_ctime;
return 0;
}
int64_t LfsClientLocalImp::SaveFile(char* fileName, const char* localFile, const int32_t flag, const char* nsAddr)
{
LOG_INFO("Not Support, save file....");
return 0;
}
int LfsClientLocalImp::FetchFile(const char* localFile, const char* fileName, const char* nsAddr)
{
LOG_INFO("Not Support, fetch file....");
return 0;
}
}/* end namespace lfs */
- Lfs ---> LfsClientLocalImp
- lfs
- lfs
- LFS
- LFS
- lfs----------
- LFS
- LFS
- lfs
- LFS简介
- LFS(1)
- LFS基本原理
- LFS制作
- LFS 笔记
- LFS(2)
- LFS(3)
- LFS(4)
- LFS(5)
- LFS ----> CommonDefine.h
- LFS --> LfsClient
- [iPhone开发之控件的使用]UIAlertView的各种属性、方法及代理的使用
- CruiseControl.Net 与StyleCop集成
- jdbc作用及步骤
- Lfs ---> LfsClientLocalImp
- 读《乔布斯传》的心得体会-
- Lfs Common --> Log
- symbian string to TTime
- 关于String转码成URL遇到的问题
- 终端服务器超出了最大允许连接数”的解决方法汇总
- [iPhone开发之控件的使用]UIActionSheet的各种属性、方法及代理的使用
- 从MTK的scat文件谈ROM和RAM的分配,管理和问题解决
- oracle监听器配置