You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/07/03 17:25:50 UTC
[commons-vfs] branch master updated: Sort methods.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push:
new e8c0317 Sort methods.
e8c0317 is described below
commit e8c0317907144356847123e0bca638f6351794e1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 3 13:25:46 2019 -0400
Sort methods.
---
.../commons/vfs2/provider/local/LocalFile.java | 184 ++++++++++-----------
1 file changed, 92 insertions(+), 92 deletions(-)
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
index e11a728..bcb770d 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
@@ -57,15 +57,6 @@ public class LocalFile extends AbstractFileObject<LocalFileSystem> {
}
/**
- * Returns the local file that this file object represents.
- *
- * @return the local file that this file object represents.
- */
- protected File getLocalFile() {
- return file;
- }
-
- /**
* Attaches this file object to its file resource.
*/
@Override
@@ -80,35 +71,13 @@ public class LocalFile extends AbstractFileObject<LocalFileSystem> {
}
/**
- * Returns the file's type.
+ * Creates this folder.
*/
@Override
- protected FileType doGetType() throws Exception {
- // JDK BUG: 6192331
- // if (!file.exists())
- if (!file.exists() && file.length() < 1) {
- return FileType.IMAGINARY;
- }
-
- if (file.isDirectory()) {
- return FileType.FOLDER;
+ protected void doCreateFolder() throws Exception {
+ if (!file.mkdirs()) {
+ throw new FileSystemException("vfs.provider.local/create-folder.error", file);
}
-
- // In doubt, treat an existing file as file
- // if (file.isFile())
- // {
- return FileType.FILE;
- // }
-
- // throw new FileSystemException("vfs.provider.local/get-type.error", file);
- }
-
- /**
- * Returns the children of the file.
- */
- @Override
- protected String[] doListChildren() throws Exception {
- return UriParser.encode(file.list());
}
/**
@@ -122,38 +91,64 @@ public class LocalFile extends AbstractFileObject<LocalFileSystem> {
}
/**
- * rename this file
+ * Returns the size of the file content (in bytes).
*/
@Override
- protected void doRename(final FileObject newFile) throws Exception {
- final LocalFile newLocalFile = (LocalFile) FileObjectUtils.getAbstractFileObject(newFile);
+ protected long doGetContentSize() throws Exception {
+ return file.length();
+ }
- if (!file.renameTo(newLocalFile.getLocalFile())) {
- throw new FileSystemException("vfs.provider.local/rename-file.error", file.toString(), newFile.toString());
- }
+ /**
+ * Creates an input stream to read the content from.
+ */
+ @Override
+ protected InputStream doGetInputStream() throws Exception {
+ return new FileInputStream(file);
}
/**
- * Creates this folder.
+ * Gets the last modified time of this file.
*/
@Override
- protected void doCreateFolder() throws Exception {
- if (!file.mkdirs()) {
- throw new FileSystemException("vfs.provider.local/create-folder.error", file);
- }
+ protected long doGetLastModifiedTime() throws FileSystemException {
+ return file.lastModified();
}
/**
- * Determines if this file can be written to.
+ * Creates an output stream to write the file content to.
*/
@Override
- protected boolean doIsWriteable() throws FileSystemException {
- return file.canWrite();
+ protected OutputStream doGetOutputStream(final boolean bAppend) throws Exception {
+ return new FileOutputStream(file.getPath(), bAppend);
}
@Override
- protected boolean doSetWritable(final boolean writable, final boolean ownerOnly) throws Exception {
- return file.setWritable(writable, ownerOnly);
+ protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception {
+ return new LocalFileRandomAccessContent(file, mode);
+ }
+
+ /**
+ * Returns the file's type.
+ */
+ @Override
+ protected FileType doGetType() throws Exception {
+ // JDK BUG: 6192331
+ // if (!file.exists())
+ if (!file.exists() && file.length() < 1) {
+ return FileType.IMAGINARY;
+ }
+
+ if (file.isDirectory()) {
+ return FileType.FOLDER;
+ }
+
+ // In doubt, treat an existing file as file
+ // if (file.isFile())
+ // {
+ return FileType.FILE;
+ // }
+
+ // throw new FileSystemException("vfs.provider.local/get-type.error", file);
}
/**
@@ -181,78 +176,83 @@ public class LocalFile extends AbstractFileObject<LocalFileSystem> {
}
@Override
- protected boolean doSetReadable(final boolean readable, final boolean ownerOnly) throws Exception {
- return file.setReadable(readable, ownerOnly);
- }
+ protected boolean doIsSameFile(final FileObject destFile) throws FileSystemException {
+ if (!FileObjectUtils.isInstanceOf(destFile, LocalFile.class)) {
+ return false;
+ }
- @Override
- protected boolean doSetExecutable(final boolean executable, final boolean ownerOnly) throws Exception {
- return file.setExecutable(executable, ownerOnly);
+ final LocalFile destLocalFile = (LocalFile) FileObjectUtils.getAbstractFileObject(destFile);
+ if (!exists() || !destLocalFile.exists()) {
+ return false;
+ }
+
+ try {
+ return file.getCanonicalPath().equals(destLocalFile.file.getCanonicalPath());
+ } catch (final IOException e) {
+ throw new FileSystemException(e);
+ }
}
/**
- * Gets the last modified time of this file.
+ * Determines if this file can be written to.
*/
@Override
- protected long doGetLastModifiedTime() throws FileSystemException {
- return file.lastModified();
+ protected boolean doIsWriteable() throws FileSystemException {
+ return file.canWrite();
}
/**
- * Sets the last modified time of this file.
- *
- * @since 2.0
+ * Returns the children of the file.
*/
@Override
- protected boolean doSetLastModifiedTime(final long modtime) throws FileSystemException {
- return file.setLastModified(modtime);
+ protected String[] doListChildren() throws Exception {
+ return UriParser.encode(file.list());
}
/**
- * Creates an input stream to read the content from.
+ * rename this file
*/
@Override
- protected InputStream doGetInputStream() throws Exception {
- return new FileInputStream(file);
+ protected void doRename(final FileObject newFile) throws Exception {
+ final LocalFile newLocalFile = (LocalFile) FileObjectUtils.getAbstractFileObject(newFile);
+
+ if (!file.renameTo(newLocalFile.getLocalFile())) {
+ throw new FileSystemException("vfs.provider.local/rename-file.error", file.toString(), newFile.toString());
+ }
}
- /**
- * Creates an output stream to write the file content to.
- */
@Override
- protected OutputStream doGetOutputStream(final boolean bAppend) throws Exception {
- return new FileOutputStream(file.getPath(), bAppend);
+ protected boolean doSetExecutable(final boolean executable, final boolean ownerOnly) throws Exception {
+ return file.setExecutable(executable, ownerOnly);
}
/**
- * Returns the size of the file content (in bytes).
+ * Sets the last modified time of this file.
+ *
+ * @since 2.0
*/
@Override
- protected long doGetContentSize() throws Exception {
- return file.length();
+ protected boolean doSetLastModifiedTime(final long modtime) throws FileSystemException {
+ return file.setLastModified(modtime);
}
@Override
- protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception {
- return new LocalFileRandomAccessContent(file, mode);
+ protected boolean doSetReadable(final boolean readable, final boolean ownerOnly) throws Exception {
+ return file.setReadable(readable, ownerOnly);
}
@Override
- protected boolean doIsSameFile(final FileObject destFile) throws FileSystemException {
- if (!FileObjectUtils.isInstanceOf(destFile, LocalFile.class)) {
- return false;
- }
-
- final LocalFile destLocalFile = (LocalFile) FileObjectUtils.getAbstractFileObject(destFile);
- if (!exists() || !destLocalFile.exists()) {
- return false;
- }
+ protected boolean doSetWritable(final boolean writable, final boolean ownerOnly) throws Exception {
+ return file.setWritable(writable, ownerOnly);
+ }
- try {
- return file.getCanonicalPath().equals(destLocalFile.file.getCanonicalPath());
- } catch (final IOException e) {
- throw new FileSystemException(e);
- }
+ /**
+ * Returns the local file that this file object represents.
+ *
+ * @return the local file that this file object represents.
+ */
+ protected File getLocalFile() {
+ return file;
}
/**