Skip to content

Commit

Permalink
Update v1 branch for new IO. (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Apr 4, 2024
1 parent a01cd54 commit 73c8aab
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
os: [ ubuntu-latest, windows-latest, macos-latest ]
# The versions should contain (at least) the lowest requirement
# and a version that is more up to date.
toit-version: [ v2.0.0-alpha.128, latest ]
toit-version: [ v2.0.0-alpha.144, latest ]
include:
- toit-version: v2.0.0-alpha.128
- toit-version: v2.0.0-alpha.144
version-name: old
- toit-version: latest
version-name: new
Expand Down
10 changes: 5 additions & 5 deletions package.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
sdk: ^2.0.0-alpha.120
sdk: ^2.0.0-alpha.144
prefixes:
fs: pkg-fs
host: pkg-host
packages:
pkg-fs:
url: github.com/toitlang/pkg-fs
name: fs
version: 2.1.0
hash: ac3933367912563055ceea4188adcead3428103c
version: 2.2.0
hash: 863280c5c62ac259d16d0d3b24df21209b461b14
prefixes:
host: pkg-host
pkg-host:
url: github.com/toitlang/pkg-host
name: host
version: 1.12.0
hash: fe5e10c56abc3fca1ef9bcba415e77fd59183cab
version: 1.15.0
hash: 2588faa0c7553eca9a85cb6f829f3df41d9466f2
6 changes: 3 additions & 3 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: cli
description: Tools, like an argument parser, to create command-line applications.
environment:
sdk: ^2.0.0-alpha.128
sdk: ^2.0.0-alpha.144
dependencies:
fs:
url: github.com/toitlang/pkg-fs
version: ^2.1.0
version: ^2.2.0
host:
url: github.com/toitlang/pkg-host
version: ^1.12.0
version: ^1.15.0
19 changes: 9 additions & 10 deletions src/cache.toit
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import fs.xdg
import host.os
import host.file
import host.directory
import io
import system
import uuid
import writer

import .utils_

Expand Down Expand Up @@ -232,7 +232,7 @@ interface FileStore:
save bytes/ByteArray

/**
Calls the given $block with a $writer.Writer.
Calls the given $block with an $io.Writer.
The $block must write its chunks to the writer.
The writer is closed after the block returns.
Expand Down Expand Up @@ -329,15 +329,15 @@ class FileStore_ implements FileStore:
file.write-content bytes --path=file-path

/**
Calls the given $block with a $writer.Writer.
Calls the given $block with a $io.Writer.
The $block must write its chunks to the writer.
The writer is closed after the block returns.
*/
save-via-writer [block]:
store_: | file-path/string |
stream := file.Stream.for-write file-path
w := writer.Writer stream
w := stream.out
try:
block.call w
finally:
Expand Down Expand Up @@ -463,9 +463,8 @@ atomic-move-directory_ source-path/string target-path/string -> none:
copy-file_ --source/string --target/string -> none:
// TODO(florian): we want to keep the permissions of the original file,
// except that we want to make the file read-only.
in := file.Stream.for-read source
out := file.Stream.for-write target
w := writer.Writer out
w.write-from in
in.close
out.close
in-stream := file.Stream.for-read source
out-stream := file.Stream.for-write target
out-stream.out.write-from in-stream.in
in-stream.close
out-stream.close
4 changes: 1 addition & 3 deletions src/config.toit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import host.os
import host.file
import host.directory
import encoding.json
import writer
import fs.xdg
import fs
import .utils_
Expand Down Expand Up @@ -188,7 +187,6 @@ class Config:
content := json.encode data
stream := file.Stream.for-write path
try:
writer := writer.Writer stream
writer.write content
stream.out.write content
finally:
stream.close

0 comments on commit 73c8aab

Please sign in to comment.