MCPcopy Create free account
hub / github.com/davidgiven/luje / properPath

Method properPath

lib/java/io/File.java:1335–1379  ·  view source on GitHub ↗

Returns a string representing the proper path for this file. If this file path is absolute, the user.dir property is not prepended, otherwise it is. @param internal is user.dir internal. @return the proper path.

(boolean internal)

Source from the content-addressed store, hash-verified

1333 * @return the proper path.
1334 */
1335 byte[] properPath(boolean internal) {
1336 if (properPath != null) {
1337 return properPath;
1338 }
1339
1340 if (isAbsolute()) {
1341 byte[] pathBytes = Util.getUTF8Bytes(path);
1342 return properPath = pathBytes;
1343 }
1344 // Check security by getting user.dir when the path is not absolute
1345 String userdir;
1346// if (internal) {
1347// userdir = AccessController.doPrivileged(new PriviAction<String>(
1348// "user.dir")); //$NON-NLS-1$
1349// } else {
1350 userdir = System.getProperty("user.dir"); //$NON-NLS-1$
1351// }
1352
1353 if (path.length() == 0) {
1354 return properPath = Util.getUTF8Bytes(userdir);
1355 }
1356 int length = userdir.length();
1357
1358 // Handle windows-like path
1359 if (path.charAt(0) == '\\') {
1360 if (length > 1 && userdir.charAt(1) == ':') {
1361 return properPath = Util.getUTF8Bytes(userdir.substring(0, 2)
1362 + path);
1363 }
1364 path = path.substring(1);
1365 }
1366
1367 // Handle separator
1368 String result = userdir;
1369 if (userdir.charAt(length - 1) != separatorChar) {
1370 if (path.charAt(0) != separatorChar) {
1371 result += separator;
1372 }
1373 } else if (path.charAt(0) == separatorChar) {
1374 result = result.substring(0, length - 2);
1375
1376 }
1377 result += path;
1378 return properPath = Util.getUTF8Bytes(result);
1379 }
1380
1381 /**
1382 * Renames this file to the name represented by the {@code dest} file. This

Callers 15

canReadMethod · 0.95
canWriteMethod · 0.95
deleteMethod · 0.95
deleteOnExitMethod · 0.95
existsMethod · 0.95
getAbsolutePathMethod · 0.95
getCanonicalPathMethod · 0.95
isDirectoryMethod · 0.95
isFileMethod · 0.95
isHiddenMethod · 0.95
lastModifiedMethod · 0.95
setLastModifiedMethod · 0.95

Calls 8

isAbsoluteMethod · 0.95
getUTF8BytesMethod · 0.95
getPropertyMethod · 0.95
lengthMethod · 0.95
charAtMethod · 0.95
substringMethod · 0.95
lengthMethod · 0.65
charAtMethod · 0.65

Tested by

no test coverage detected