mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +00:00
always create file if necessary in Java_java_io_FileOutputStream_open
Previously, we would only create the file if it did not already exist *and* we weren't appending. Now we do so whether appending or not.
This commit is contained in:
parent
d12d33d716
commit
b6978c6c68
@ -624,7 +624,9 @@ Java_java_io_FileOutputStream_open(JNIEnv* e, jclass, jstring path, jboolean app
|
|||||||
{
|
{
|
||||||
string_t chars = getChars(e, path);
|
string_t chars = getChars(e, path);
|
||||||
if (chars) {
|
if (chars) {
|
||||||
int fd = doOpen(e, chars, append ? (O_WRONLY | O_APPEND) : (O_WRONLY | O_CREAT | O_TRUNC));
|
int fd = doOpen(e, chars, append
|
||||||
|
? (O_WRONLY | O_CREAT | O_APPEND)
|
||||||
|
: (O_WRONLY | O_CREAT | O_TRUNC));
|
||||||
releaseChars(e, path, chars);
|
releaseChars(e, path, chars);
|
||||||
return fd;
|
return fd;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,14 +4,9 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class FileOutput {
|
public class FileOutput {
|
||||||
|
private static void test(boolean appendFirst) throws IOException {
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
FileOutputStream f = new FileOutputStream("test.txt");
|
FileOutputStream f = new FileOutputStream("test.txt", appendFirst);
|
||||||
f.write("Hello world!\n".getBytes());
|
f.write("Hello world!\n".getBytes());
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
@ -37,4 +32,9 @@ public class FileOutput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
test(false);
|
||||||
|
test(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user