Skip to content

Commit

Permalink
$mol_file improve copy api 2
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Oct 21, 2024
1 parent 65bc5ee commit 1eda482
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion file/file.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -114,6 +114,10 @@ namespace $ {

}

override copy(to: string) {
$node.fs.copyFileSync(this.path(), to)
}

@ $mol_action
override drop() {
$node.fs.unlinkSync( this.path() )
Expand Down
12 changes: 6 additions & 6 deletions file/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1eda482

Please sign in to comment.