fix(libsdk): add IsDir and IsRegular for java.

Signed-off-by: baihailong <baihailong@oppo.com>
This commit is contained in:
baihailong 2024-06-21 15:12:39 +08:00 committed by AmazingChi
parent 92edf40c3e
commit a98a67358d
4 changed files with 19 additions and 6 deletions

View File

@ -127,4 +127,7 @@ public interface CfsLibrary extends Library {
int cfs_getsummary(long cid, String path, SummaryInfo.ByReference summaryInfo, String useCache, int goroutineNum);
int cfs_refreshsummary(long cid, String path, int goroutineNum);
char cfs_IsDir(int mode);
char cfs_IsRegular(int mode);
}

View File

@ -67,6 +67,16 @@ public class CfsMount {
return libcfs.cfs_getcwd(this.cid);
}
public boolean IsDir(int mode) {
int result = libcfs.cfs_IsDir(mode);
return result != 0;
}
public boolean IsRegular(int mode) {
int result = libcfs.cfs_IsRegular(mode);
return result != 0;
}
public int getAttr(String path, CfsLibrary.StatInfo stat) throws FileNotFoundException {
int result = libcfs.cfs_getattr(this.cid, path, stat);
if (result != SUCCESS) {

View File

@ -155,8 +155,8 @@ extern int cfs_unlock_dir(int64_t id, char *path);
extern int cfs_get_dir_lock(int64_t id, char *path, int64_t *lock_id, char **valid_time);
extern int cfs_symlink(int64_t id, char *src_path, char *dst_path);
extern int cfs_link(int64_t id, char *src_path, char *dst_path);
extern char cfs_IsDir(mode_t mode);
extern char cfs_IsRegular(mode_t mode);
extern int cfs_IsDir(mode_t mode);
extern int cfs_IsRegular(mode_t mode);
#ifdef __cplusplus
}

View File

@ -257,21 +257,21 @@ type client struct {
}
//export cfs_IsDir
func cfs_IsDir(mode C.mode_t) C.char {
func cfs_IsDir(mode C.mode_t) C.int {
var isDir uint8 = 0
if (mode & C.S_IFMT) == C.S_IFDIR {
isDir = 1
}
return C.char(isDir)
return C.int(isDir)
}
//export cfs_IsRegular
func cfs_IsRegular(mode C.mode_t) C.char {
func cfs_IsRegular(mode C.mode_t) C.int {
var isRegular uint8 = 0
if (mode & C.S_IFMT) == C.S_IFREG {
isRegular = 1
}
return C.char(isRegular)
return C.int(isRegular)
}
//export cfs_symlink