Skip to content

Commit 94209f0

Browse files
committed
We don't need create option
1 parent 75dbd8c commit 94209f0

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

java_runtime/src/classes/java/io/file_input_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl FileInputStream {
3636
let path = jvm.invoke_virtual(&file, "getPath", "()Ljava/lang/String;", ()).await?;
3737
let path = JavaLangString::to_rust_string(jvm, &path).await?;
3838

39-
let rust_file = context.open(&path, false, false).await.unwrap();
39+
let rust_file = context.open(&path, false).await.unwrap();
4040

4141
let fd = FileDescriptor::from_file(jvm, rust_file).await?;
4242

java_runtime/src/classes/java/io/file_output_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl FileOutputStream {
4242
let path = jvm.invoke_virtual(&file, "getPath", "()Ljava/lang/String;", ()).await?;
4343
let path = JavaLangString::to_rust_string(jvm, &path).await?;
4444

45-
let file = context.open(&path, true, true).await.unwrap();
45+
let file = context.open(&path, true).await.unwrap();
4646
let fd = FileDescriptor::from_file(jvm, file).await?;
4747

4848
jvm.put_field(&mut this, "fd", "Ljava/io/FileDescriptor;", fd).await?;

java_runtime/src/classes/java/io/random_access_file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ impl RandomAccessFile {
5353
let name = JavaLangString::to_rust_string(jvm, &name).await?;
5454
let mode = JavaLangString::to_rust_string(jvm, &mode).await?;
5555

56-
let create = mode.contains('w');
56+
let write = mode.contains('w');
5757

58-
let rust_file = context.open(&name, create, create).await.unwrap();
58+
let rust_file = context.open(&name, write).await.unwrap();
5959
let fd = FileDescriptor::from_file(jvm, rust_file).await?;
6060
jvm.put_field(&mut this, "fd", "Ljava/io/FileDescriptor;", fd).await?;
6161

java_runtime/src/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub trait Runtime: Sync + Send + DynClone {
2727
fn stdout(&self) -> IOResult<Box<dyn File>>;
2828
fn stderr(&self) -> IOResult<Box<dyn File>>;
2929

30-
async fn open(&self, path: &str, write: bool, create: bool) -> IOResult<Box<dyn File>>;
30+
async fn open(&self, path: &str, write: bool) -> IOResult<Box<dyn File>>;
3131
async fn unlink(&self, path: &str) -> IOResult<()>;
3232
async fn metadata(&self, path: &str) -> IOResult<FileStat>;
3333

@@ -117,7 +117,7 @@ pub mod test {
117117
Err(IOError::NotFound)
118118
}
119119

120-
async fn open(&self, path: &str, _write: bool, _create: bool) -> IOResult<Box<dyn File>> {
120+
async fn open(&self, path: &str, _write: bool) -> IOResult<Box<dyn File>> {
121121
let entry = self.filesystem.get(path);
122122
if let Some(data) = entry {
123123
Ok(Box::new(DummyFile::new(data.clone())) as Box<_>)

src/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ where
116116
Ok(Box::new(WriteStreamFile::new(stderr())))
117117
}
118118

119-
async fn open(&self, path: &str, write: bool, create: bool) -> IOResult<Box<dyn File>> {
120-
Ok(Box::new(FileImpl::new(path, write, create)))
119+
async fn open(&self, path: &str, write: bool) -> IOResult<Box<dyn File>> {
120+
Ok(Box::new(FileImpl::new(path, write)))
121121
}
122122

123123
async fn unlink(&self, path: &str) -> IOResult<()> {

src/runtime/io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ pub struct FileImpl {
131131
}
132132

133133
impl FileImpl {
134-
pub fn new(path: &str, write: bool, create: bool) -> Self {
134+
pub fn new(path: &str, write: bool) -> Self {
135135
let mut options = OpenOptions::new();
136-
let file = options.read(true).write(write).create(create).open(path).unwrap();
136+
let file = options.read(true).write(write).create(write).open(path).unwrap();
137137

138138
Self {
139139
file: Arc::new(Mutex::new(file)),

0 commit comments

Comments
 (0)