@@ -46,6 +46,15 @@ public RetCode mkdir(String path) throws ContractException {
46
46
transactionReceipt , tr -> bfsPrecompiled .getMkdirOutput (tr ).getValue1 ());
47
47
}
48
48
49
+ // deprecated, use list(String absolutePath, BigInteger offset, BigInteger limit)
50
+
51
+ /**
52
+ * @param path absolute path
53
+ * @return If path is a directory, then return sub files; if path is a link, then return
54
+ * fileName and link-address in ext.
55
+ * @deprecated use {@link #list(String, BigInteger, BigInteger)} instead.
56
+ */
57
+ @ Deprecated
49
58
public List <BFSPrecompiled .BfsInfo > list (String path ) throws ContractException {
50
59
Tuple2 <BigInteger , DynamicArray <BFSPrecompiled .BfsInfo >> listOutput =
51
60
bfsPrecompiled .list (path );
@@ -63,6 +72,13 @@ public List<BFSPrecompiled.BfsInfo> list(String path) throws ContractException {
63
72
return listOutput .getValue2 ().getValue ();
64
73
}
65
74
75
+ /**
76
+ * @param path absolute path
77
+ * @return If path is a directory, then return sub files; if path is a link, then return
78
+ * fileName and link-address in ext.
79
+ * @deprecated use {@link #list(String, BigInteger, BigInteger)} instead.
80
+ */
81
+ @ Deprecated
66
82
public List <BFSInfo > listBFSInfo (String path ) throws ContractException {
67
83
Tuple2 <BigInteger , DynamicArray <BFSPrecompiled .BfsInfo >> listOutput =
68
84
bfsPrecompiled .list (path );
@@ -102,6 +118,40 @@ public Tuple2<BigInteger, List<BFSInfo>> listBFSInfo(
102
118
.collect (Collectors .toList ()));
103
119
}
104
120
121
+ /**
122
+ * check the path file is exist in BFS
123
+ *
124
+ * @param absolutePath absolute path in BFS
125
+ * @return if file exist, then return a BFSInfo; if not exist, then return null
126
+ */
127
+ public BFSInfo isExist (String absolutePath ) throws ContractException {
128
+ PrecompiledVersionCheck .LS_PAGE_VERSION .checkVersion (currentVersion );
129
+ if (absolutePath .endsWith ("/" )) {
130
+ absolutePath = absolutePath .substring (0 , absolutePath .length () - 1 );
131
+ }
132
+ int index = absolutePath .lastIndexOf ('/' );
133
+ String parent = absolutePath .substring (0 , index );
134
+ String child = absolutePath .substring (index + 1 );
135
+ int offset = 0 ;
136
+ int limit = 500 ;
137
+ while (true ) {
138
+ Tuple2 <BigInteger , DynamicArray <BFSPrecompiled .BfsInfo >> listOutput =
139
+ bfsPrecompiled .list (
140
+ parent , BigInteger .valueOf (offset ), BigInteger .valueOf (limit ));
141
+ if (!listOutput .getValue1 ().equals (BigInteger .ZERO )) {
142
+ break ;
143
+ }
144
+ for (BFSPrecompiled .BfsInfo bfsInfo : listOutput .getValue2 ().getValue ()) {
145
+ if (bfsInfo .fileName .equals (child )) {
146
+ return BFSInfo .fromPrecompiledBfs (bfsInfo );
147
+ }
148
+ }
149
+ offset += limit + 1 ;
150
+ limit = listOutput .getValue1 ().intValue ();
151
+ }
152
+ return null ;
153
+ }
154
+
105
155
public RetCode link (String name , String version , String contractAddress , String abi )
106
156
throws ContractException {
107
157
TransactionReceipt transactionReceipt =
0 commit comments