more TDB
This commit is contained in:
parent
5c9c9695e5
commit
5f90bae8bb
|
@ -35,3 +35,35 @@ i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes) {
|
|||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int tdbPRead(int fd, void *pData, int count, i64 offset) {
|
||||
void *pBuf;
|
||||
int nbytes;
|
||||
i64 ioffset;
|
||||
int iread;
|
||||
|
||||
pBuf = pData;
|
||||
nbytes = count;
|
||||
ioffset = offset;
|
||||
while (nbytes > 0) {
|
||||
iread = pread(fd, pBuf, nbytes, ioffset);
|
||||
if (iread < 0) {
|
||||
/* TODO */
|
||||
} else if (iread == 0) {
|
||||
return (count - iread);
|
||||
}
|
||||
|
||||
nbytes = nbytes - iread;
|
||||
pBuf = (void *)((u8 *)pBuf + iread);
|
||||
ioffset += iread;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int tdbWrite(int fd, void *pData, int count) {
|
||||
// TODO
|
||||
return write(fd, pData, count);
|
||||
}
|
||||
#endif
|
|
@ -209,7 +209,7 @@ int tdbPagerCommit(SPager *pPager) {
|
|||
tdbOsFSync(pPager->fd);
|
||||
|
||||
tdbOsClose(pPager->jfd);
|
||||
remove(pPager->jFileName);
|
||||
tdbOsRemove(pPager->jFileName);
|
||||
// pPager->jfd = -1;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -33,24 +33,6 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// int tdbCheckFileAccess(const char *pathname, int mode) {
|
||||
// int flags = 0;
|
||||
|
||||
// if (mode & TDB_F_OK) {
|
||||
// flags |= F_OK;
|
||||
// }
|
||||
|
||||
// if (mode & TDB_R_OK) {
|
||||
// flags |= R_OK;
|
||||
// }
|
||||
|
||||
// if (mode & TDB_W_OK) {
|
||||
// flags |= W_OK;
|
||||
// }
|
||||
|
||||
// return access(pathname, flags);
|
||||
// }
|
||||
|
||||
int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize) {
|
||||
struct stat st;
|
||||
int ret;
|
||||
|
@ -65,33 +47,3 @@ int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize) {
|
|||
*pSize = file_size / pgSize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdbPRead(int fd, void *pData, int count, i64 offset) {
|
||||
void *pBuf;
|
||||
int nbytes;
|
||||
i64 ioffset;
|
||||
int iread;
|
||||
|
||||
pBuf = pData;
|
||||
nbytes = count;
|
||||
ioffset = offset;
|
||||
while (nbytes > 0) {
|
||||
iread = pread(fd, pBuf, nbytes, ioffset);
|
||||
if (iread < 0) {
|
||||
/* TODO */
|
||||
} else if (iread == 0) {
|
||||
return (count - iread);
|
||||
}
|
||||
|
||||
nbytes = nbytes - iread;
|
||||
pBuf = (void *)((u8 *)pBuf + iread);
|
||||
ioffset += iread;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int tdbWrite(int fd, void *pData, int count) {
|
||||
// TODO
|
||||
return write(fd, pData, count);
|
||||
}
|
|
@ -53,6 +53,7 @@ typedef TdFilePtr tdb_fd_t;
|
|||
#define tdbOsWrite taosWriteFile
|
||||
#define tdbOsFSync taosFsyncFile
|
||||
#define tdbOsLSeek taosLSeekFile
|
||||
#define tdbOsRemove remove
|
||||
|
||||
/* directory */
|
||||
#define tdbOsMkdir taosMkDir
|
||||
|
@ -72,6 +73,7 @@ i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes);
|
|||
|
||||
#define tdbOsFSync fsync
|
||||
#define tdbOsLSeek lseek
|
||||
#define tdbOsRemove remove
|
||||
|
||||
/* directory */
|
||||
#define tdbOsMkdir mkdir
|
||||
|
|
|
@ -30,16 +30,8 @@ extern "C" {
|
|||
|
||||
int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique);
|
||||
|
||||
// #define TDB_F_OK 0x1
|
||||
// #define TDB_R_OK 0x2
|
||||
// #define TDB_W_OK 0x4
|
||||
// int tdbCheckFileAccess(const char *pathname, int mode);
|
||||
|
||||
int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize);
|
||||
|
||||
int tdbPRead(int fd, void *pData, int count, i64 offset);
|
||||
int tdbWrite(int fd, void *pData, int count);
|
||||
|
||||
#define TDB_REALLOC(PTR, SIZE) \
|
||||
({ \
|
||||
void *nPtr; \
|
||||
|
|
Loading…
Reference in New Issue