Skip to content

Skeleton for package:io_file #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/io_file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: package:io_file

permissions: read-all

on:
# Run CI on pushes to the main branch, and on PRs against main.
push:
branches: [ main ]
paths:
- '.github/workflows/io_file.yml'
- 'pkgs/io_file/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/io_file.yml'
- 'pkgs/io_file/**'
schedule:
- cron: '0 0 * * 0' # weekly

defaults:
run:
working-directory: pkgs/io_file

jobs:
analyze_and_format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
sdk: stable
- run: dart pub get
- run: dart analyze --fatal-infos
- run: dart format --output=none --set-exit-if-changed .

desktop-vm-test:
strategy:
fail-fast: false
matrix:
sdk: [stable, dev]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
sdk: ${{ matrix.sdk }}

- run: dart test --test-randomize-ordering-seed=random --platform vm

web-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
sdk: stable

- run: dart test --test-randomize-ordering-seed=random --platform chrome
7 changes: 7 additions & 0 deletions pkgs/io_file/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/

# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock
3 changes: 3 additions & 0 deletions pkgs/io_file/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.1.0-wip

- Initial version.
27 changes: 27 additions & 0 deletions pkgs/io_file/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2025, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 changes: 21 additions & 0 deletions pkgs/io_file/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
This package is an **experimental** reimplementation of the `dart:io` file
system API using FFI.

See
[package:io_file - a pure dart file system API](https://docs.google.com/document/d/17dPegdklLKQz4fjrRDHaN0ld7FlmK0prncZQUTx68nk/edit?usp=sharing)

## Status: Experimental

**NOTE**: This package is currently experimental and published under the
[labs.dart.dev](https://dart.dev/dart-team-packages) pub publisher in order to
solicit feedback.

For packages in the labs.dart.dev publisher we generally plan to either graduate
the package into a supported publisher (dart.dev, tools.dart.dev) after a period
of feedback and iteration, or discontinue the package. These packages have a
much higher expected rate of API and breaking changes.

Your feedback is valuable and will help us evolve this package. For general
feedback, suggestions, and comments, please file an issue in the
[bug tracker](https://github.com/dart-lang/labs/issues).

23 changes: 23 additions & 0 deletions pkgs/io_file/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need / want this customization? You could also start w/ just dart_flutter_team_lints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied these from dart-lang/http. They seem reasonable to me.

language:
strict-casts: true
strict-raw-types: true
strict-inference: true

linter:
rules:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_private_typedef_functions
- avoid_returning_this
- avoid_unused_constructor_parameters
- cascade_invocations
- join_return_with_assignment
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- prefer_const_declarations
- prefer_expression_function_bodies
- use_string_buffers
6 changes: 6 additions & 0 deletions pkgs/io_file/example/io_file_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:io_file/io_file.dart';

void main() {
var awesome = Awesome();
print('awesome: ${awesome.isAwesome}');
}
8 changes: 8 additions & 0 deletions pkgs/io_file/lib/io_file.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// Support for doing something awesome.
///
/// More dartdocs go here.
library;

export 'src/io_file_base.dart';

// TODO: Export any libraries intended for clients of this package.
6 changes: 6 additions & 0 deletions pkgs/io_file/lib/src/io_file_base.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// TODO: Put public facing types in this file.

/// Checks if you are awesome. Spoiler: you are.
class Awesome {
bool get isAwesome => true;
}
12 changes: 12 additions & 0 deletions pkgs/io_file/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: io_file
description: A starting point for Dart libraries or applications.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to update this description now (and the corresponding one on the root repo readme).

version: 0.1.0-wip
repository: https://github.com/dart-lang/labs/tree/main/pkgs/io_file
publish_to: none

environment:
sdk: ^3.7.0

dev_dependencies:
dart_flutter_team_lints: ^3.4.0
test: ^1.24.0
16 changes: 16 additions & 0 deletions pkgs/io_file/test/io_file_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:io_file/io_file.dart';
import 'package:test/test.dart';

void main() {
group('A group of tests', () {
final awesome = Awesome();

setUp(() {
// Additional setup goes here.
});

test('First Test', () {
expect(awesome.isAwesome, isTrue);
});
});
}