Skip to content

Commit

Permalink
Moving FileAccessMode from "file_access_mode.dart" to "options.dart"
Browse files Browse the repository at this point in the history
Remove [FileAccessModeExtension]
  • Loading branch information
shehabmohamed0 committed Dec 16, 2024
1 parent 27bb332 commit 4276742
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 35 deletions.
1 change: 0 additions & 1 deletion dio/lib/dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export 'src/adapter.dart';
export 'src/cancel_token.dart';
export 'src/dio.dart';
export 'src/dio_exception.dart';
export 'src/file_access_mode.dart';
export 'src/dio_mixin.dart' hide InterceptorState, InterceptorResultType;
export 'src/form_data.dart';
export 'src/headers.dart';
Expand Down
1 change: 0 additions & 1 deletion dio/lib/src/dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'cancel_token.dart';
import 'dio/dio_for_native.dart'
if (dart.library.js_interop) 'dio/dio_for_browser.dart'
if (dart.library.html) 'dio/dio_for_browser.dart';
import 'file_access_mode.dart';
import 'dio_mixin.dart';
import 'headers.dart';
import 'options.dart';
Expand Down
8 changes: 3 additions & 5 deletions dio/lib/src/dio/dio_for_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import '../adapters/io_adapter.dart';
import '../cancel_token.dart';
import '../dio.dart';
import '../dio_exception.dart';
import '../file_access_mode.dart';
import '../dio_mixin.dart';
import '../headers.dart';
import '../options.dart';
Expand Down Expand Up @@ -98,10 +97,9 @@ class DioForNative with DioMixin implements Dio {
// because it can write all bytes by once. Consider that the file is
// a very big size (up to 1 Gigabytes), it will be expensive in memory.
RandomAccessFile raf = file.openSync(
mode: fileAccessMode.map(
write: () => FileMode.write,
append: () => FileMode.append,
),
mode: fileAccessMode == FileAccessMode.write
? FileMode.write
: FileMode.append,
);

// Create a Completer to notify the success/error state.
Expand Down
1 change: 0 additions & 1 deletion dio/lib/src/dio_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'adapter.dart';
import 'cancel_token.dart';
import 'dio.dart';
import 'dio_exception.dart';
import 'file_access_mode.dart';
import 'form_data.dart';
import 'headers.dart';
import 'interceptors/imply_content_type.dart';
Expand Down
27 changes: 0 additions & 27 deletions dio/lib/src/file_access_mode.dart

This file was deleted.

14 changes: 14 additions & 0 deletions dio/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -753,3 +753,17 @@ class _RequestConfig {
ResponseDecoder? responseDecoder;
late ListFormat listFormat;
}

/// {@template dio.options.FileAccessMode}
/// The file access mode when downloading a file, corresponds to a subset of
/// dart:io::[FileMode].
/// {@endtemplate}
enum FileAccessMode {
/// Mode for opening a file for reading and writing. The file is overwritten
/// if it already exists. The file is created if it does not already exist.
write,

/// Mode for opening a file for reading and writing to the end of it.
/// The file is created if it does not already exist.
append,
}

0 comments on commit 4276742

Please sign in to comment.