| 183 | } |
| 184 | |
| 185 | public static long getDirSize(Path path) { |
| 186 | long pFind = findFirst(path.$().ptr()); |
| 187 | if (pFind > 0L) { |
| 188 | int len = path.size(); |
| 189 | try { |
| 190 | long totalSize = 0L; |
| 191 | do { |
| 192 | long nameUtf8Ptr = findName(pFind); |
| 193 | path.trimTo(len).concat(nameUtf8Ptr).$(); |
| 194 | if (findType(pFind) == Files.DT_FILE) { |
| 195 | totalSize += length(path.$()); |
| 196 | } else if (notDots(nameUtf8Ptr)) { |
| 197 | totalSize += getDirSize(path); |
| 198 | } |
| 199 | } |
| 200 | while (findNext(pFind) > 0); |
| 201 | return totalSize; |
| 202 | } finally { |
| 203 | findClose(pFind); |
| 204 | path.trimTo(len); |
| 205 | } |
| 206 | } |
| 207 | return 0L; |
| 208 | } |
| 209 | |
| 210 | public static long getDiskFreeSpace(LPSZ path) { |
| 211 | if (path != null) { |