diff --git a/file/file.node.ts b/file/file.node.ts index afa17d4736..aebff59a16 100644 --- a/file/file.node.ts +++ b/file/file.node.ts @@ -81,7 +81,7 @@ namespace $ { @ $mol_mem override stat(next? : $mol_file_stat | null, virt?: 'virt') { - this.copy_sync() + if (next === undefined) this.copy_sync() let stat = next const path = this.path() @@ -114,6 +114,10 @@ namespace $ { } + override copy(to: string) { + $node.fs.copyFileSync(this.path(), to) + } + @ $mol_action override drop() { $node.fs.unlinkSync( this.path() ) diff --git a/file/file.ts b/file/file.ts index 59fa6e0125..166a951d33 100644 --- a/file/file.ts +++ b/file/file.ts @@ -126,19 +126,19 @@ namespace $ { buffer( next? : Uint8Array ) { return next ?? new Uint8Array } @ $mol_mem - copy_src(path?: string) { - return path ?? null - } + copy_src(path?: string) { return path ?? null } + + copy(to: string) {} @ $mol_mem copy_sync() { const src_path = this.copy_src() - if (! src_path) return null + if (! src_path) return false const src = this.$.$mol_file.absolute(src_path) src.stat() - $node.fs.copyFileSync(src.path(), this.path()) + src.copy(this.path()) - return null + return true } @ $mol_mem