You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2005/10/01 13:40:22 UTC
svn commit: r292959 - in /jakarta/commons/proper/io/trunk: RELEASE-NOTES.txt
src/java/org/apache/commons/io/output/LockableFileWriter.java
Author: scolebourne
Date: Sat Oct 1 04:40:17 2005
New Revision: 292959
URL: http://svn.apache.org/viewcvs?rev=292959&view=rev
Log:
Improve validation and directory creation in LockableFileWriter
Modified:
jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/LockableFileWriter.java
Modified: jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt?rev=292959&r1=292958&r2=292959&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt (original)
+++ jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt Sat Oct 1 04:40:17 2005
@@ -22,21 +22,22 @@
Source compatible - Yes
Semantic compatible - Yes, except:
-- FileUtils.touch()
+- FileUtils.writeStringToFile()
+ A null encoding previously used 'ISO-8859-1', now it uses the platform default
+ Generally this will make no difference
+
+- LockableFileWriter
+ Improved validation and now create directories if necesssary
+
+plus these bug fixes may affect you semantically:
+- FileUtils.touch() (Bug fix 29821)
Now creates the file if it did not previously exist
- (Bug fix 29821)
-- FileUtils.toFile(URL)
+- FileUtils.toFile(URL) (Bug fix 32575)
Now handles escape syntax such as %20
- (Bug fix 32575)
-- FileUtils.sizeOfDirectory()
+- FileUtils.sizeOfDirectory() (Bug fix 36801)
May now return a size of 0 if the directory is security restricted
- (Bug fix 36801)
-
-- FileUtils.writeStringToFile()
- A null encoding previously used 'ISO-8859-1', now it uses the platform default
- Generally this will make no difference
Deprecations from 1.0
@@ -173,6 +174,8 @@
- LockableFileWriter - encoding support [36825]
Add support for character encodings to LockableFileWriter
+ Improve the validation
+ Create directories if necesssary
- IOUtils and EndianUtils are no longer final [28978]
Allows developers to have subclasses if desired
Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/LockableFileWriter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/LockableFileWriter.java?rev=292959&r1=292958&r2=292959&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/LockableFileWriter.java (original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/LockableFileWriter.java Sat Oct 1 04:40:17 2005
@@ -22,6 +22,8 @@
import java.io.OutputStreamWriter;
import java.io.Writer;
+import org.apache.commons.io.FileUtils;
+
/**
* FileWriter that will create and honor lock files to allow simple
* cross thread file lock handling.
@@ -153,19 +155,25 @@
public LockableFileWriter(File file, String encoding, boolean append,
String lockDir) throws IOException {
super();
+ // init file to create/append
file = file.getAbsoluteFile();
- if (file.exists()) {
- if (file.isDirectory()) {
- throw new IOException("File specified is a directory");
- }
- } else if (file.getParentFile() != null) {
- file.getParentFile().mkdirs();
+ if (file.getParentFile() != null) {
+ FileUtils.forceMkdir(file.getParentFile());
}
+ if (file.isDirectory()) {
+ throw new IOException("File specified is a directory");
+ }
+
+ // init lock file
if (lockDir == null) {
lockDir = System.getProperty("java.io.tmpdir");
}
- testLockDir(new File(lockDir));
- this.lockFile = new File(lockDir, file.getName() + LCK);
+ File lockDirFile = new File(lockDir);
+ FileUtils.forceMkdir(lockDirFile);
+ testLockDir(lockDirFile);
+ this.lockFile = new File(lockDirFile, file.getName() + LCK);
+
+ // init wrapped writer
try {
createLock();
if (encoding == null) {
@@ -178,7 +186,6 @@
this.lockFile.delete();
throw ioe;
}
-
this.out = new FileWriter(file.getAbsolutePath(), append);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org