@capacitor/filesystem 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,10 +9,13 @@ Pod::Spec.new do |s|
9
9
  s.license = package['license']
10
10
  s.homepage = package['repository']['url']
11
11
  s.author = package['author']
12
- s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
12
+ s.source = { :git => package['repository']['url'], :tag => "v#{s.version}" }
13
+ s.source_files = [
14
+ 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}',
15
+ 'packages/capacitor-plugin/ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
16
+ ]
14
17
  s.ios.deployment_target = '15.0'
15
18
  s.dependency 'Capacitor'
16
- s.dependency 'IONFilesystemLib', spec='~> 1.0.1'
19
+ s.dependency 'IONFilesystemLib', spec='~> 1.1.0'
17
20
  s.swift_version = '5.1'
18
21
  end
package/Package.swift CHANGED
@@ -11,7 +11,7 @@ let package = Package(
11
11
  ],
12
12
  dependencies: [
13
13
  .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
14
- .package(url: "https://github.com/ionic-team/ion-ios-filesystem.git", from: "1.0.1")
14
+ .package(url: "https://github.com/ionic-team/ion-ios-filesystem.git", from: "1.1.0")
15
15
  ],
16
16
  targets: [
17
17
  .target(
package/README.md CHANGED
@@ -541,11 +541,13 @@ We recommend using the @capacitor/file-transfer plugin instead, in conjunction w
541
541
 
542
542
  #### ReadFileOptions
543
543
 
544
- | Prop | Type | Description | Since |
545
- | --------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
546
- | **`path`** | <code>string</code> | The path of the file to read | 1.0.0 |
547
- | **`directory`** | <code><a href="#directory">Directory</a></code> | The <a href="#directory">`Directory`</a> to read the file from | 1.0.0 |
548
- | **`encoding`** | <code><a href="#encoding">Encoding</a></code> | The encoding to read the file in, if not provided, data is read as binary and returned as base64 encoded. Pass <a href="#encoding">Encoding.UTF8</a> to read data as string | 1.0.0 |
544
+ | Prop | Type | Description | Default | Since |
545
+ | --------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------- | ----- |
546
+ | **`path`** | <code>string</code> | The path of the file to read | | 1.0.0 |
547
+ | **`directory`** | <code><a href="#directory">Directory</a></code> | The <a href="#directory">`Directory`</a> to read the file from | | 1.0.0 |
548
+ | **`encoding`** | <code><a href="#encoding">Encoding</a></code> | The encoding to read the file in, if not provided, data is read as binary and returned as base64 encoded. Pass <a href="#encoding">Encoding.UTF8</a> to read data as string | | 1.0.0 |
549
+ | **`offset`** | <code>number</code> | The offset to start reading the file from, in bytes. Native only (not available in web). Can be used in conjunction with length to partially read files. | <code>0</code> | 8.1.0 |
550
+ | **`length`** | <code>number</code> | The length of data to read, in bytes. Any non-positive value means to read to the end of the file. Native only (not available in web). Can be used in conjunction with offset to partially read files. | <code>-1</code> | 8.1.0 |
549
551
 
550
552
 
551
553
  #### ReadFileInChunksOptions
@@ -58,7 +58,7 @@ repositories {
58
58
 
59
59
  dependencies {
60
60
  implementation fileTree(dir: 'libs', include: ['*.jar'])
61
- implementation "io.ionic.libs:ionfilesystem-android:1.0.0"
61
+ implementation "io.ionic.libs:ionfilesystem-android:1.1.0"
62
62
  implementation project(':capacitor-android')
63
63
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
64
64
 
@@ -97,5 +97,7 @@ fun Throwable.toFilesystemError(methodName: String): FilesystemErrors.ErrorInfo
97
97
  is IONFILEExceptions.CopyRenameFailed.NoParentDirectory ->
98
98
  FilesystemErrors.missingParentDirectories
99
99
 
100
+ is IllegalArgumentException -> FilesystemErrors.invalidInputMethod(methodName)
101
+
100
102
  else -> FilesystemErrors.operationFailed(methodName, this.localizedMessage ?: "")
101
103
  }
@@ -1,6 +1,7 @@
1
1
  package com.capacitorjs.plugins.filesystem
2
2
 
3
3
  import com.getcapacitor.PluginCall
4
+ import io.ionic.libs.ionfilesystemlib.model.IONFILEConstants
4
5
  import io.ionic.libs.ionfilesystemlib.model.IONFILEEncoding
5
6
  import io.ionic.libs.ionfilesystemlib.model.IONFILEFolderType
6
7
  import io.ionic.libs.ionfilesystemlib.model.IONFILEReadInChunksOptions
@@ -13,6 +14,8 @@ internal const val INPUT_APPEND = "append"
13
14
  private const val INPUT_PATH = "path"
14
15
  private const val INPUT_DIRECTORY = "directory"
15
16
  private const val INPUT_ENCODING = "encoding"
17
+ private const val INPUT_OFFSET = "offset"
18
+ private const val INPUT_LENGTH = "length"
16
19
  private const val INPUT_CHUNK_SIZE = "chunkSize"
17
20
  private const val INPUT_DATA = "data"
18
21
  private const val INPUT_RECURSIVE = "recursive"
@@ -52,7 +55,15 @@ internal data class DoubleUri(
52
55
  internal fun PluginCall.getReadFileOptions(): ReadFileOptions? {
53
56
  val uri = getSingleIONFILEUri() ?: return null
54
57
  val encoding = IONFILEEncoding.fromEncodingName(getString(INPUT_ENCODING))
55
- return ReadFileOptions(uri = uri, options = IONFILEReadOptions(encoding))
58
+ val offsetAndLength = getOffsetAndLength()
59
+ return ReadFileOptions(
60
+ uri = uri,
61
+ options = IONFILEReadOptions(
62
+ encoding,
63
+ offset = offsetAndLength.first,
64
+ length = offsetAndLength.second
65
+ )
66
+ )
56
67
  }
57
68
 
58
69
  /**
@@ -62,9 +73,15 @@ internal fun PluginCall.getReadFileInChunksOptions(): ReadFileInChunksOptions? {
62
73
  val uri = getSingleIONFILEUri() ?: return null
63
74
  val encoding = IONFILEEncoding.fromEncodingName(getString(INPUT_ENCODING))
64
75
  val chunkSize = getInt(INPUT_CHUNK_SIZE)?.takeIf { it > 0 } ?: return null
76
+ val offsetAndLength = getOffsetAndLength()
65
77
  return ReadFileInChunksOptions(
66
78
  uri = uri,
67
- options = IONFILEReadInChunksOptions(encoding, chunkSize)
79
+ options = IONFILEReadInChunksOptions(
80
+ encoding,
81
+ chunkSize = chunkSize,
82
+ offset = offsetAndLength.first,
83
+ length = offsetAndLength.second
84
+ )
68
85
  )
69
86
  }
70
87
 
@@ -123,6 +140,11 @@ internal fun PluginCall.getSingleIONFILEUri(): IONFILEUri.Unresolved? {
123
140
  return unresolvedUri(path, directoryAlias)
124
141
  }
125
142
 
143
+ private fun PluginCall.getOffsetAndLength(): Pair<Int, Int> = Pair(
144
+ getInt(INPUT_OFFSET)?.takeIf { it >= 0 } ?: 0,
145
+ getInt(INPUT_LENGTH)?.takeIf { it > 0 } ?: IONFILEConstants.LENGTH_READ_TIL_EOF
146
+ )
147
+
126
148
  private fun unresolvedUri(path: String, directoryAlias: String?) = IONFILEUri.Unresolved(
127
149
  parentFolder = IONFILEFolderType.fromStringAlias(directoryAlias),
128
150
  uriPath = path
package/dist/docs.json CHANGED
@@ -512,6 +512,38 @@
512
512
  "Encoding"
513
513
  ],
514
514
  "type": "Encoding"
515
+ },
516
+ {
517
+ "name": "offset",
518
+ "tags": [
519
+ {
520
+ "text": "8.1.0",
521
+ "name": "since"
522
+ },
523
+ {
524
+ "text": "0",
525
+ "name": "default"
526
+ }
527
+ ],
528
+ "docs": "The offset to start reading the file from, in bytes.\nNative only (not available in web).\nCan be used in conjunction with length to partially read files.",
529
+ "complexTypes": [],
530
+ "type": "number | undefined"
531
+ },
532
+ {
533
+ "name": "length",
534
+ "tags": [
535
+ {
536
+ "text": "8.1.0",
537
+ "name": "since"
538
+ },
539
+ {
540
+ "text": "-1",
541
+ "name": "default"
542
+ }
543
+ ],
544
+ "docs": "The length of data to read, in bytes.\nAny non-positive value means to read to the end of the file.\nNative only (not available in web).\nCan be used in conjunction with offset to partially read files.",
545
+ "complexTypes": [],
546
+ "type": "number | undefined"
515
547
  }
516
548
  ]
517
549
  },
@@ -203,6 +203,25 @@ export interface ReadFileOptions {
203
203
  * @since 1.0.0
204
204
  */
205
205
  encoding?: Encoding;
206
+ /**
207
+ * The offset to start reading the file from, in bytes.
208
+ * Native only (not available in web).
209
+ * Can be used in conjunction with length to partially read files.
210
+ *
211
+ * @since 8.1.0
212
+ * @default 0
213
+ */
214
+ offset?: number;
215
+ /**
216
+ * The length of data to read, in bytes.
217
+ * Any non-positive value means to read to the end of the file.
218
+ * Native only (not available in web).
219
+ * Can be used in conjunction with offset to partially read files.
220
+ *
221
+ * @since 8.1.0
222
+ * @default -1
223
+ */
224
+ length?: number;
206
225
  }
207
226
  export interface ReadFileInChunksOptions extends ReadFileOptions {
208
227
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAQA,MAAM,CAAN,IAAY,SA8FX;AA9FD,WAAY,SAAS;IACnB;;;;;;;;;;;OAWG;IACH,oCAAuB,CAAA;IAEvB;;;;;;;OAOG;IACH,0BAAa,CAAA;IAEb;;;;;;;OAOG;IACH,gCAAmB,CAAA;IAEnB;;;;;;OAMG;IACH,4BAAe,CAAA;IAEf;;;;;;;;;;OAUG;IACH,kCAAqB,CAAA;IAErB;;;;;;;;;;OAUG;IAEH,iDAAoC,CAAA;IACpC;;;;;;OAMG;IACH,6CAAgC,CAAA;IAEhC;;;;;OAKG;IACH,gDAAmC,CAAA;IAEnC;;;;;OAKG;IACH,oCAAuB,CAAA;AACzB,CAAC,EA9FW,SAAS,KAAT,SAAS,QA8FpB;AAED,MAAM,CAAN,IAAY,QAyBX;AAzBD,WAAY,QAAQ;IAClB;;;;OAIG;IACH,yBAAa,CAAA;IAEb;;;;;;OAMG;IACH,2BAAe,CAAA;IAEf;;;;;;OAMG;IACH,2BAAe,CAAA;AACjB,CAAC,EAzBW,QAAQ,KAAR,QAAQ,QAyBnB;AA+mBD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import type { HttpOptions, PermissionState, PluginListenerHandle } from '@capacitor/core';\n\nexport type CallbackID = string;\n\nexport interface PermissionStatus {\n publicStorage: PermissionState;\n}\n\nexport enum Directory {\n /**\n * The Documents directory.\n * On iOS it's the app's documents directory.\n * Use this directory to store user-generated content.\n * On Android it's the Public Documents folder, so it's accessible from other apps.\n * It's not accessible on Android 10 unless the app enables legacy External Storage\n * by adding `android:requestLegacyExternalStorage=\"true\"` in the `application` tag\n * in the `AndroidManifest.xml`.\n * On Android 11 or newer the app can only access the files/folders the app created.\n *\n * @since 1.0.0\n */\n Documents = 'DOCUMENTS',\n\n /**\n * The Data directory.\n * On iOS it will use the Documents directory.\n * On Android it's the directory holding application files.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.0.0\n */\n Data = 'DATA',\n\n /**\n * The Library directory.\n * On iOS it will use the Library directory.\n * On Android it's the directory holding application files.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.1.0\n */\n Library = 'LIBRARY',\n\n /**\n * The Cache directory.\n * Can be deleted in cases of low memory, so use this directory to write app-specific files.\n * that your app can re-create easily.\n *\n * @since 1.0.0\n */\n Cache = 'CACHE',\n\n /**\n * The external directory.\n * On iOS it will use the Documents directory.\n * On Android it's the directory on the primary shared/external\n * storage device where the application can place persistent files it owns.\n * These files are internal to the applications, and not typically visible\n * to the user as media.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.0.0\n */\n External = 'EXTERNAL',\n\n /**\n * The external storage directory.\n * On iOS it will use the Documents directory.\n * On Android it's the primary shared/external storage directory.\n * It's not accessible on Android 10 unless the app enables legacy External Storage\n * by adding `android:requestLegacyExternalStorage=\"true\"` in the `application` tag\n * in the `AndroidManifest.xml`.\n * It's not accessible on Android 11 or newer.\n *\n * @since 1.0.0\n */\n\n ExternalStorage = 'EXTERNAL_STORAGE',\n /**\n * The external cache directory.\n * On iOS it will use the Documents directory.\n * On Android it's the primary shared/external cache.\n *\n * @since 7.1.0\n */\n ExternalCache = 'EXTERNAL_CACHE',\n\n /**\n * The Library directory without cloud backup. Used in iOS.\n * On Android it's the directory holding application files.\n *\n * @since 7.1.0\n */\n LibraryNoCloud = 'LIBRARY_NO_CLOUD',\n\n /**\n * A temporary directory for iOS.\n * On Android it's the directory holding the application cache.\n *\n * @since 7.1.0\n */\n Temporary = 'TEMPORARY',\n}\n\nexport enum Encoding {\n /**\n * Eight-bit UCS Transformation Format\n *\n * @since 1.0.0\n */\n UTF8 = 'utf8',\n\n /**\n * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the\n * Unicode character set\n * This encoding is only supported on Android.\n *\n * @since 1.0.0\n */\n ASCII = 'ascii',\n\n /**\n * Sixteen-bit UCS Transformation Format, byte order identified by an\n * optional byte-order mark\n * This encoding is only supported on Android.\n *\n * @since 1.0.0\n */\n UTF16 = 'utf16',\n}\n\nexport interface WriteFileOptions {\n /**\n * The path of the file to write\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The data to write\n *\n * Note: Blob data is only supported on Web.\n *\n * @since 1.0.0\n */\n data: string | Blob;\n\n /**\n * The `Directory` to store the file in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to write the file in. If not provided, data\n * is written as base64 encoded.\n *\n * Pass Encoding.UTF8 to write data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n\n /**\n * Whether to create any missing parent directories.\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface AppendFileOptions {\n /**\n * The path of the file to append\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The data to write\n *\n * @since 1.0.0\n */\n data: string;\n\n /**\n * The `Directory` to store the file in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to write the file in. If not provided, data\n * is written as base64 encoded.\n *\n * Pass Encoding.UTF8 to write data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n}\n\nexport interface ReadFileOptions {\n /**\n * The path of the file to read\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to read the file from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to read the file in, if not provided, data\n * is read as binary and returned as base64 encoded.\n *\n * Pass Encoding.UTF8 to read data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n}\n\nexport interface ReadFileInChunksOptions extends ReadFileOptions {\n /**\n * Size of the chunks in bytes.\n *\n * @since 7.1.0\n */\n chunkSize: number;\n}\n\nexport interface DeleteFileOptions {\n /**\n * The path of the file to delete\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to delete the file from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface MkdirOptions {\n /**\n * The path of the new directory\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to make the new directory in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * Whether to create any missing parent directories as well.\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface RmdirOptions {\n /**\n * The path of the directory to remove\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to remove the directory from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * Whether to recursively remove the contents of the directory\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface ReaddirOptions {\n /**\n * The path of the directory to read\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to list files from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface GetUriOptions {\n /**\n * The path of the file to get the URI for\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to get the file under\n *\n * @since 1.0.0\n */\n directory: Directory;\n}\n\nexport interface StatOptions {\n /**\n * The path of the file to get data about\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to get the file under\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface CopyOptions {\n /**\n * The existing file or directory\n *\n * @since 1.0.0\n */\n from: string;\n\n /**\n * The destination file or directory\n *\n * @since 1.0.0\n */\n to: string;\n\n /**\n * The `Directory` containing the existing file or directory\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The `Directory` containing the destination file or directory. If not supplied will use the 'directory'\n * parameter as the destination\n *\n * @since 1.0.0\n */\n toDirectory?: Directory;\n}\n\nexport type RenameOptions = CopyOptions;\n\nexport interface ReadFileResult {\n /**\n * The representation of the data contained in the file\n *\n * Note: Blob is only available on Web. On native, the data is returned as a string.\n *\n * @since 1.0.0\n */\n data: string | Blob;\n}\n\nexport interface WriteFileResult {\n /**\n * The uri where the file was written into\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport interface ReaddirResult {\n /**\n * List of files and directories inside the directory\n *\n * @since 1.0.0\n */\n files: FileInfo[];\n}\n\nexport interface FileInfo {\n /**\n * Name of the file or directory.\n *\n * @since 7.1.0\n */\n name: string;\n\n /**\n * Type of the file.\n *\n * @since 4.0.0\n */\n type: 'directory' | 'file';\n\n /**\n * Size of the file in bytes.\n *\n * @since 4.0.0\n */\n size: number;\n\n /**\n * Time of creation in milliseconds.\n *\n * It's not available on Android 7 and older devices.\n *\n * @since 7.1.0\n */\n ctime?: number;\n\n /**\n * Time of last modification in milliseconds.\n *\n * @since 7.1.0\n */\n mtime: number;\n\n /**\n * The uri of the file.\n *\n * @since 4.0.0\n */\n uri: string;\n}\n\nexport interface GetUriResult {\n /**\n * The uri of the file\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport type StatResult = FileInfo;\nexport interface CopyResult {\n /**\n * The uri where the file was copied into\n *\n * @since 4.0.0\n */\n uri: string;\n}\n\nexport interface DownloadFileOptions extends HttpOptions {\n /**\n * The path the downloaded file should be moved to.\n *\n * @since 5.1.0\n */\n path: string;\n /**\n * The directory to write the file to.\n * If this option is used, filePath can be a relative path rather than absolute.\n * The default is the `DATA` directory.\n *\n * @since 5.1.0\n */\n directory?: Directory;\n /**\n * An optional listener function to receive downloaded progress events.\n * If this option is used, progress event should be dispatched on every chunk received.\n * Chunks are throttled to every 100ms on Android/iOS to avoid slowdowns.\n *\n * @since 5.1.0\n */\n progress?: boolean;\n /**\n * Whether to create any missing parent directories.\n *\n * @default false\n * @since 5.1.2\n */\n recursive?: boolean;\n}\n\nexport interface DownloadFileResult {\n /**\n * The path the file was downloaded to.\n *\n * @since 5.1.0\n */\n path?: string;\n /**\n * The blob data of the downloaded file.\n * This is only available on web.\n *\n * @since 5.1.0\n */\n blob?: Blob;\n}\n\nexport interface ProgressStatus {\n /**\n * The url of the file being downloaded.\n *\n * @since 5.1.0\n */\n url: string;\n /**\n * The number of bytes downloaded so far.\n *\n * @since 5.1.0\n */\n bytes: number;\n /**\n * The total number of bytes to download for this file.\n *\n * @since 5.1.0\n */\n contentLength: number;\n}\n\n/**\n * Callback for receiving chunks read from a file, or error if something went wrong.\n *\n * @since 7.1.0\n */\nexport type ReadFileInChunksCallback = (chunkRead: ReadFileResult | null, err?: any) => void;\n\n/**\n * A listener function that receives progress events.\n *\n * @since 5.1.0\n */\nexport type ProgressListener = (progress: ProgressStatus) => void;\n\nexport interface FilesystemPlugin {\n /**\n * Check read/write permissions.\n * Required on Android, only when using `Directory.Documents` or\n * `Directory.ExternalStorage`.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request read/write permissions.\n * Required on Android, only when using `Directory.Documents` or\n * `Directory.ExternalStorage`.\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Read a file from disk\n *\n * @since 1.0.0\n */\n readFile(options: ReadFileOptions): Promise<ReadFileResult>;\n\n /**\n * Read a file from disk, in chunks.\n * Native only (not available in web).\n * Use the callback to receive each read chunk.\n * If empty chunk is returned, it means file has been completely read.\n *\n * @since 7.1.0\n */\n readFileInChunks(options: ReadFileInChunksOptions, callback: ReadFileInChunksCallback): Promise<CallbackID>;\n\n /**\n * Write a file to disk in the specified location on device\n *\n * @since 1.0.0\n */\n writeFile(options: WriteFileOptions): Promise<WriteFileResult>;\n\n /**\n * Append to a file on disk in the specified location on device\n *\n * @since 1.0.0\n */\n appendFile(options: AppendFileOptions): Promise<void>;\n\n /**\n * Delete a file from disk\n *\n * @since 1.0.0\n */\n deleteFile(options: DeleteFileOptions): Promise<void>;\n\n /**\n * Create a directory.\n *\n * @since 1.0.0\n */\n mkdir(options: MkdirOptions): Promise<void>;\n\n /**\n * Remove a directory\n *\n * @since 1.0.0\n */\n rmdir(options: RmdirOptions): Promise<void>;\n\n /**\n * Return a list of files from the directory (not recursive)\n *\n * @since 1.0.0\n */\n readdir(options: ReaddirOptions): Promise<ReaddirResult>;\n\n /**\n * Return full File URI for a path and directory\n *\n * @since 1.0.0\n */\n getUri(options: GetUriOptions): Promise<GetUriResult>;\n\n /**\n * Return data about a file\n *\n * @since 1.0.0\n */\n stat(options: StatOptions): Promise<StatResult>;\n\n /**\n * Rename a file or directory\n *\n * @since 1.0.0\n */\n rename(options: RenameOptions): Promise<void>;\n\n /**\n * Copy a file or directory\n *\n * @since 1.0.0\n */\n copy(options: CopyOptions): Promise<CopyResult>;\n\n /**\n * Perform a http request to a server and download the file to the specified destination.\n *\n * This method has been deprecated since version 7.1.0.\n * We recommend using the @capacitor/file-transfer plugin instead, in conjunction with this plugin.\n *\n * @since 5.1.0\n * @deprecated Use the @capacitor/file-transfer plugin instead.\n */\n downloadFile(options: DownloadFileOptions): Promise<DownloadFileResult>;\n\n /**\n * Add a listener to file download progress events.\n *\n * This method has been deprecated since version 7.1.0.\n * We recommend using the @capacitor/file-transfer plugin instead, in conjunction with this plugin.\n *\n * @since 5.1.0\n * @deprecated Use the @capacitor/file-transfer plugin instead.\n */\n addListener(eventName: 'progress', listenerFunc: ProgressListener): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * This method has been deprecated since version 7.1.0.\n * We recommend using the @capacitor/file-transfer plugin instead, in conjunction with this plugin.\n *\n * @since 5.2.0\n * @deprecated Use the @capacitor/file-transfer plugin instead.\n */\n removeAllListeners(): Promise<void>;\n}\n\n/**\n * Structure for errors returned by the plugin.\n *\n * `code` follows \"OS-PLUG-FILE-XXXX\" format\n *\n * @since 1.0.0\n */\nexport type PluginError = {\n code: string;\n message: string;\n};\n\n/**\n * @deprecated Use `ReadFileOptions`.\n * @since 1.0.0\n */\nexport type FileReadOptions = ReadFileOptions;\n\n/**\n * @deprecated Use `ReadFileResult`.\n * @since 1.0.0\n */\nexport type FileReadResult = ReadFileResult;\n\n/**\n * @deprecated Use `WriteFileOptions`.\n * @since 1.0.0\n */\nexport type FileWriteOptions = WriteFileOptions;\n\n/**\n * @deprecated Use `WriteFileResult`.\n * @since 1.0.0\n */\nexport type FileWriteResult = WriteFileResult;\n\n/**\n * @deprecated Use `AppendFileOptions`.\n * @since 1.0.0\n */\nexport type FileAppendOptions = AppendFileOptions;\n\n/**\n * @deprecated Use `DeleteFileOptions`.\n * @since 1.0.0\n */\nexport type FileDeleteOptions = DeleteFileOptions;\n\n/**\n * @deprecated Use `Directory`.\n * @since 1.0.0\n */\nexport const FilesystemDirectory = Directory;\n\n/**\n * @deprecated Use `Encoding`.\n * @since 1.0.0\n */\nexport const FilesystemEncoding = Encoding;\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAQA,MAAM,CAAN,IAAY,SA8FX;AA9FD,WAAY,SAAS;IACnB;;;;;;;;;;;OAWG;IACH,oCAAuB,CAAA;IAEvB;;;;;;;OAOG;IACH,0BAAa,CAAA;IAEb;;;;;;;OAOG;IACH,gCAAmB,CAAA;IAEnB;;;;;;OAMG;IACH,4BAAe,CAAA;IAEf;;;;;;;;;;OAUG;IACH,kCAAqB,CAAA;IAErB;;;;;;;;;;OAUG;IAEH,iDAAoC,CAAA;IACpC;;;;;;OAMG;IACH,6CAAgC,CAAA;IAEhC;;;;;OAKG;IACH,gDAAmC,CAAA;IAEnC;;;;;OAKG;IACH,oCAAuB,CAAA;AACzB,CAAC,EA9FW,SAAS,KAAT,SAAS,QA8FpB;AAED,MAAM,CAAN,IAAY,QAyBX;AAzBD,WAAY,QAAQ;IAClB;;;;OAIG;IACH,yBAAa,CAAA;IAEb;;;;;;OAMG;IACH,2BAAe,CAAA;IAEf;;;;;;OAMG;IACH,2BAAe,CAAA;AACjB,CAAC,EAzBW,QAAQ,KAAR,QAAQ,QAyBnB;AAooBD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import type { HttpOptions, PermissionState, PluginListenerHandle } from '@capacitor/core';\n\nexport type CallbackID = string;\n\nexport interface PermissionStatus {\n publicStorage: PermissionState;\n}\n\nexport enum Directory {\n /**\n * The Documents directory.\n * On iOS it's the app's documents directory.\n * Use this directory to store user-generated content.\n * On Android it's the Public Documents folder, so it's accessible from other apps.\n * It's not accessible on Android 10 unless the app enables legacy External Storage\n * by adding `android:requestLegacyExternalStorage=\"true\"` in the `application` tag\n * in the `AndroidManifest.xml`.\n * On Android 11 or newer the app can only access the files/folders the app created.\n *\n * @since 1.0.0\n */\n Documents = 'DOCUMENTS',\n\n /**\n * The Data directory.\n * On iOS it will use the Documents directory.\n * On Android it's the directory holding application files.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.0.0\n */\n Data = 'DATA',\n\n /**\n * The Library directory.\n * On iOS it will use the Library directory.\n * On Android it's the directory holding application files.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.1.0\n */\n Library = 'LIBRARY',\n\n /**\n * The Cache directory.\n * Can be deleted in cases of low memory, so use this directory to write app-specific files.\n * that your app can re-create easily.\n *\n * @since 1.0.0\n */\n Cache = 'CACHE',\n\n /**\n * The external directory.\n * On iOS it will use the Documents directory.\n * On Android it's the directory on the primary shared/external\n * storage device where the application can place persistent files it owns.\n * These files are internal to the applications, and not typically visible\n * to the user as media.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.0.0\n */\n External = 'EXTERNAL',\n\n /**\n * The external storage directory.\n * On iOS it will use the Documents directory.\n * On Android it's the primary shared/external storage directory.\n * It's not accessible on Android 10 unless the app enables legacy External Storage\n * by adding `android:requestLegacyExternalStorage=\"true\"` in the `application` tag\n * in the `AndroidManifest.xml`.\n * It's not accessible on Android 11 or newer.\n *\n * @since 1.0.0\n */\n\n ExternalStorage = 'EXTERNAL_STORAGE',\n /**\n * The external cache directory.\n * On iOS it will use the Documents directory.\n * On Android it's the primary shared/external cache.\n *\n * @since 7.1.0\n */\n ExternalCache = 'EXTERNAL_CACHE',\n\n /**\n * The Library directory without cloud backup. Used in iOS.\n * On Android it's the directory holding application files.\n *\n * @since 7.1.0\n */\n LibraryNoCloud = 'LIBRARY_NO_CLOUD',\n\n /**\n * A temporary directory for iOS.\n * On Android it's the directory holding the application cache.\n *\n * @since 7.1.0\n */\n Temporary = 'TEMPORARY',\n}\n\nexport enum Encoding {\n /**\n * Eight-bit UCS Transformation Format\n *\n * @since 1.0.0\n */\n UTF8 = 'utf8',\n\n /**\n * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the\n * Unicode character set\n * This encoding is only supported on Android.\n *\n * @since 1.0.0\n */\n ASCII = 'ascii',\n\n /**\n * Sixteen-bit UCS Transformation Format, byte order identified by an\n * optional byte-order mark\n * This encoding is only supported on Android.\n *\n * @since 1.0.0\n */\n UTF16 = 'utf16',\n}\n\nexport interface WriteFileOptions {\n /**\n * The path of the file to write\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The data to write\n *\n * Note: Blob data is only supported on Web.\n *\n * @since 1.0.0\n */\n data: string | Blob;\n\n /**\n * The `Directory` to store the file in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to write the file in. If not provided, data\n * is written as base64 encoded.\n *\n * Pass Encoding.UTF8 to write data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n\n /**\n * Whether to create any missing parent directories.\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface AppendFileOptions {\n /**\n * The path of the file to append\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The data to write\n *\n * @since 1.0.0\n */\n data: string;\n\n /**\n * The `Directory` to store the file in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to write the file in. If not provided, data\n * is written as base64 encoded.\n *\n * Pass Encoding.UTF8 to write data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n}\n\nexport interface ReadFileOptions {\n /**\n * The path of the file to read\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to read the file from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to read the file in, if not provided, data\n * is read as binary and returned as base64 encoded.\n *\n * Pass Encoding.UTF8 to read data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n\n /**\n * The offset to start reading the file from, in bytes.\n * Native only (not available in web).\n * Can be used in conjunction with length to partially read files.\n *\n * @since 8.1.0\n * @default 0\n */\n offset?: number;\n\n /**\n * The length of data to read, in bytes.\n * Any non-positive value means to read to the end of the file.\n * Native only (not available in web).\n * Can be used in conjunction with offset to partially read files.\n *\n * @since 8.1.0\n * @default -1\n */\n length?: number;\n}\n\nexport interface ReadFileInChunksOptions extends ReadFileOptions {\n /**\n * Size of the chunks in bytes.\n *\n * @since 7.1.0\n */\n chunkSize: number;\n}\n\nexport interface DeleteFileOptions {\n /**\n * The path of the file to delete\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to delete the file from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface MkdirOptions {\n /**\n * The path of the new directory\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to make the new directory in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * Whether to create any missing parent directories as well.\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface RmdirOptions {\n /**\n * The path of the directory to remove\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to remove the directory from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * Whether to recursively remove the contents of the directory\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface ReaddirOptions {\n /**\n * The path of the directory to read\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to list files from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface GetUriOptions {\n /**\n * The path of the file to get the URI for\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to get the file under\n *\n * @since 1.0.0\n */\n directory: Directory;\n}\n\nexport interface StatOptions {\n /**\n * The path of the file to get data about\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to get the file under\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface CopyOptions {\n /**\n * The existing file or directory\n *\n * @since 1.0.0\n */\n from: string;\n\n /**\n * The destination file or directory\n *\n * @since 1.0.0\n */\n to: string;\n\n /**\n * The `Directory` containing the existing file or directory\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The `Directory` containing the destination file or directory. If not supplied will use the 'directory'\n * parameter as the destination\n *\n * @since 1.0.0\n */\n toDirectory?: Directory;\n}\n\nexport type RenameOptions = CopyOptions;\n\nexport interface ReadFileResult {\n /**\n * The representation of the data contained in the file\n *\n * Note: Blob is only available on Web. On native, the data is returned as a string.\n *\n * @since 1.0.0\n */\n data: string | Blob;\n}\n\nexport interface WriteFileResult {\n /**\n * The uri where the file was written into\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport interface ReaddirResult {\n /**\n * List of files and directories inside the directory\n *\n * @since 1.0.0\n */\n files: FileInfo[];\n}\n\nexport interface FileInfo {\n /**\n * Name of the file or directory.\n *\n * @since 7.1.0\n */\n name: string;\n\n /**\n * Type of the file.\n *\n * @since 4.0.0\n */\n type: 'directory' | 'file';\n\n /**\n * Size of the file in bytes.\n *\n * @since 4.0.0\n */\n size: number;\n\n /**\n * Time of creation in milliseconds.\n *\n * It's not available on Android 7 and older devices.\n *\n * @since 7.1.0\n */\n ctime?: number;\n\n /**\n * Time of last modification in milliseconds.\n *\n * @since 7.1.0\n */\n mtime: number;\n\n /**\n * The uri of the file.\n *\n * @since 4.0.0\n */\n uri: string;\n}\n\nexport interface GetUriResult {\n /**\n * The uri of the file\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport type StatResult = FileInfo;\nexport interface CopyResult {\n /**\n * The uri where the file was copied into\n *\n * @since 4.0.0\n */\n uri: string;\n}\n\nexport interface DownloadFileOptions extends HttpOptions {\n /**\n * The path the downloaded file should be moved to.\n *\n * @since 5.1.0\n */\n path: string;\n /**\n * The directory to write the file to.\n * If this option is used, filePath can be a relative path rather than absolute.\n * The default is the `DATA` directory.\n *\n * @since 5.1.0\n */\n directory?: Directory;\n /**\n * An optional listener function to receive downloaded progress events.\n * If this option is used, progress event should be dispatched on every chunk received.\n * Chunks are throttled to every 100ms on Android/iOS to avoid slowdowns.\n *\n * @since 5.1.0\n */\n progress?: boolean;\n /**\n * Whether to create any missing parent directories.\n *\n * @default false\n * @since 5.1.2\n */\n recursive?: boolean;\n}\n\nexport interface DownloadFileResult {\n /**\n * The path the file was downloaded to.\n *\n * @since 5.1.0\n */\n path?: string;\n /**\n * The blob data of the downloaded file.\n * This is only available on web.\n *\n * @since 5.1.0\n */\n blob?: Blob;\n}\n\nexport interface ProgressStatus {\n /**\n * The url of the file being downloaded.\n *\n * @since 5.1.0\n */\n url: string;\n /**\n * The number of bytes downloaded so far.\n *\n * @since 5.1.0\n */\n bytes: number;\n /**\n * The total number of bytes to download for this file.\n *\n * @since 5.1.0\n */\n contentLength: number;\n}\n\n/**\n * Callback for receiving chunks read from a file, or error if something went wrong.\n *\n * @since 7.1.0\n */\nexport type ReadFileInChunksCallback = (chunkRead: ReadFileResult | null, err?: any) => void;\n\n/**\n * A listener function that receives progress events.\n *\n * @since 5.1.0\n */\nexport type ProgressListener = (progress: ProgressStatus) => void;\n\nexport interface FilesystemPlugin {\n /**\n * Check read/write permissions.\n * Required on Android, only when using `Directory.Documents` or\n * `Directory.ExternalStorage`.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request read/write permissions.\n * Required on Android, only when using `Directory.Documents` or\n * `Directory.ExternalStorage`.\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Read a file from disk\n *\n * @since 1.0.0\n */\n readFile(options: ReadFileOptions): Promise<ReadFileResult>;\n\n /**\n * Read a file from disk, in chunks.\n * Native only (not available in web).\n * Use the callback to receive each read chunk.\n * If empty chunk is returned, it means file has been completely read.\n *\n * @since 7.1.0\n */\n readFileInChunks(options: ReadFileInChunksOptions, callback: ReadFileInChunksCallback): Promise<CallbackID>;\n\n /**\n * Write a file to disk in the specified location on device\n *\n * @since 1.0.0\n */\n writeFile(options: WriteFileOptions): Promise<WriteFileResult>;\n\n /**\n * Append to a file on disk in the specified location on device\n *\n * @since 1.0.0\n */\n appendFile(options: AppendFileOptions): Promise<void>;\n\n /**\n * Delete a file from disk\n *\n * @since 1.0.0\n */\n deleteFile(options: DeleteFileOptions): Promise<void>;\n\n /**\n * Create a directory.\n *\n * @since 1.0.0\n */\n mkdir(options: MkdirOptions): Promise<void>;\n\n /**\n * Remove a directory\n *\n * @since 1.0.0\n */\n rmdir(options: RmdirOptions): Promise<void>;\n\n /**\n * Return a list of files from the directory (not recursive)\n *\n * @since 1.0.0\n */\n readdir(options: ReaddirOptions): Promise<ReaddirResult>;\n\n /**\n * Return full File URI for a path and directory\n *\n * @since 1.0.0\n */\n getUri(options: GetUriOptions): Promise<GetUriResult>;\n\n /**\n * Return data about a file\n *\n * @since 1.0.0\n */\n stat(options: StatOptions): Promise<StatResult>;\n\n /**\n * Rename a file or directory\n *\n * @since 1.0.0\n */\n rename(options: RenameOptions): Promise<void>;\n\n /**\n * Copy a file or directory\n *\n * @since 1.0.0\n */\n copy(options: CopyOptions): Promise<CopyResult>;\n\n /**\n * Perform a http request to a server and download the file to the specified destination.\n *\n * This method has been deprecated since version 7.1.0.\n * We recommend using the @capacitor/file-transfer plugin instead, in conjunction with this plugin.\n *\n * @since 5.1.0\n * @deprecated Use the @capacitor/file-transfer plugin instead.\n */\n downloadFile(options: DownloadFileOptions): Promise<DownloadFileResult>;\n\n /**\n * Add a listener to file download progress events.\n *\n * This method has been deprecated since version 7.1.0.\n * We recommend using the @capacitor/file-transfer plugin instead, in conjunction with this plugin.\n *\n * @since 5.1.0\n * @deprecated Use the @capacitor/file-transfer plugin instead.\n */\n addListener(eventName: 'progress', listenerFunc: ProgressListener): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * This method has been deprecated since version 7.1.0.\n * We recommend using the @capacitor/file-transfer plugin instead, in conjunction with this plugin.\n *\n * @since 5.2.0\n * @deprecated Use the @capacitor/file-transfer plugin instead.\n */\n removeAllListeners(): Promise<void>;\n}\n\n/**\n * Structure for errors returned by the plugin.\n *\n * `code` follows \"OS-PLUG-FILE-XXXX\" format\n *\n * @since 1.0.0\n */\nexport type PluginError = {\n code: string;\n message: string;\n};\n\n/**\n * @deprecated Use `ReadFileOptions`.\n * @since 1.0.0\n */\nexport type FileReadOptions = ReadFileOptions;\n\n/**\n * @deprecated Use `ReadFileResult`.\n * @since 1.0.0\n */\nexport type FileReadResult = ReadFileResult;\n\n/**\n * @deprecated Use `WriteFileOptions`.\n * @since 1.0.0\n */\nexport type FileWriteOptions = WriteFileOptions;\n\n/**\n * @deprecated Use `WriteFileResult`.\n * @since 1.0.0\n */\nexport type FileWriteResult = WriteFileResult;\n\n/**\n * @deprecated Use `AppendFileOptions`.\n * @since 1.0.0\n */\nexport type FileAppendOptions = AppendFileOptions;\n\n/**\n * @deprecated Use `DeleteFileOptions`.\n * @since 1.0.0\n */\nexport type FileDeleteOptions = DeleteFileOptions;\n\n/**\n * @deprecated Use `Directory`.\n * @since 1.0.0\n */\nexport const FilesystemDirectory = Directory;\n\n/**\n * @deprecated Use `Encoding`.\n * @since 1.0.0\n */\nexport const FilesystemEncoding = Encoding;\n"]}
@@ -26,6 +26,8 @@ struct Constants {
26
26
  static let directory = "directory"
27
27
  static let encoding = "encoding"
28
28
  static let chunkSize = "chunkSize"
29
+ static let offset = "offset"
30
+ static let length = "length"
29
31
  static let from = "from"
30
32
  static let path = "path"
31
33
  static let recursive = "recursive"
@@ -3,8 +3,8 @@ import IONFilesystemLib
3
3
 
4
4
  enum FilesystemOperation {
5
5
  // Read Operations
6
- case readFile(url: URL, encoding: IONFILEEncoding)
7
- case readFileInChunks(url: URL, encoding: IONFILEEncoding, chunkSize: Int)
6
+ case readFile(url: URL, encoding: IONFILEEncoding, offset: Int, length: Int)
7
+ case readFileInChunks(url: URL, encoding: IONFILEEncoding, chunkSize: Int, offset: Int, length: Int)
8
8
  case readdir(url: URL)
9
9
  case stat(url: URL)
10
10
  case getUri(url: URL)
@@ -16,11 +16,11 @@ class FilesystemOperationExecutor {
16
16
  var resultData: PluginCallResultData?
17
17
 
18
18
  switch operation {
19
- case .readFile(let url, let encoding):
20
- let data = try service.readEntireFile(atURL: url, withEncoding: encoding).textValue
19
+ case .readFile(let url, let encoding, let offset, let length):
20
+ let data = try service.readEntireFile(atURL: url, withEncoding: encoding, andOffset: offset, andLength: length).textValue
21
21
  resultData = [Constants.ResultDataKey.data: data]
22
- case .readFileInChunks(let url, let encoding, let chunkSize):
23
- try processFileInChunks(at: url, withEncoding: encoding, chunkSize: chunkSize, for: operation, call)
22
+ case .readFileInChunks(let url, let encoding, let chunkSize, let offset, let length):
23
+ try processFileInChunks(at: url, withEncoding: encoding, chunkSize: chunkSize, offset: offset, length: length, for: operation, call)
24
24
  return
25
25
  case .write(let url, let encodingMapper, let recursive):
26
26
  try service.saveFile(atURL: url, withEncodingAndData: encodingMapper, includeIntermediateDirectories: recursive)
@@ -56,9 +56,9 @@ class FilesystemOperationExecutor {
56
56
  }
57
57
 
58
58
  private extension FilesystemOperationExecutor {
59
- func processFileInChunks(at url: URL, withEncoding encoding: IONFILEEncoding, chunkSize: Int, for operation: FilesystemOperation, _ call: CAPPluginCall) throws {
59
+ func processFileInChunks(at url: URL, withEncoding encoding: IONFILEEncoding, chunkSize: Int, offset: Int, length: Int, for operation: FilesystemOperation, _ call: CAPPluginCall) throws {
60
60
  let chunkSizeToUse = chunkSizeToUse(basedOn: chunkSize, and: encoding)
61
- try service.readFileInChunks(atURL: url, withEncoding: encoding, andChunkSize: chunkSizeToUse)
61
+ try service.readFileInChunks(atURL: url, withEncoding: encoding, andChunkSize: chunkSizeToUse, andOffset: offset, andLength: length)
62
62
  .sink(receiveCompletion: { completion in
63
63
  switch completion {
64
64
  case .finished:
@@ -82,8 +82,8 @@ private extension FilesystemOperationExecutor {
82
82
  var path = ""
83
83
  var method: IONFileMethod = IONFileMethod.getUri
84
84
  switch operation {
85
- case .readFile(let url, _): path = url.absoluteString; method = .readFile
86
- case .readFileInChunks(let url, _, _): path = url.absoluteString; method = .readFileInChunks
85
+ case .readFile(let url, _, _, _): path = url.absoluteString; method = .readFile
86
+ case .readFileInChunks(let url, _, _, _, _): path = url.absoluteString; method = .readFileInChunks
87
87
  case .write(let url, _, _): path = url.absoluteString; method = .writeFile
88
88
  case .append(let url, _, _): path = url.absoluteString; method = .appendFile
89
89
  case .delete(let url): path = url.absoluteString; method = .deleteFile
@@ -59,8 +59,10 @@ private extension FilesystemPlugin {
59
59
  */
60
60
  @objc func readFile(_ call: CAPPluginCall) {
61
61
  let encoding = call.getEncoding(Constants.MethodParameter.encoding)
62
+ let offset = call.getInt(Constants.MethodParameter.offset) ?? 0
63
+ let length = call.getInt(Constants.MethodParameter.length) ?? -1
62
64
  performSinglePathOperation(call) {
63
- .readFile(url: $0, encoding: encoding)
65
+ .readFile(url: $0, encoding: encoding, offset: offset, length: length)
64
66
  }
65
67
  }
66
68
 
@@ -69,8 +71,10 @@ private extension FilesystemPlugin {
69
71
  guard let chunkSize = call.getInt(Constants.MethodParameter.chunkSize) else {
70
72
  return call.handleError(.invalidInput(method: call.getIONFileMethod()))
71
73
  }
74
+ let offset = call.getInt(Constants.MethodParameter.offset) ?? 0
75
+ let length = call.getInt(Constants.MethodParameter.length) ?? -1
72
76
  performSinglePathOperation(call) {
73
- .readFileInChunks(url: $0, encoding: encoding, chunkSize: chunkSize)
77
+ .readFileInChunks(url: $0, encoding: encoding, chunkSize: chunkSize, offset: offset, length: length)
74
78
  }
75
79
  }
76
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/filesystem",
3
- "version": "8.0.0",
3
+ "version": "8.1.0",
4
4
  "description": "The Filesystem API provides a NodeJS-like API for working with files on the device.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -43,7 +43,8 @@
43
43
  "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
44
44
  "clean": "rimraf ./dist",
45
45
  "watch": "tsc --watch",
46
- "prepublishOnly": "npm run build"
46
+ "prepublishOnly": "npm run build",
47
+ "publish:cocoapod": "pod trunk push ./CapacitorFilesystem.podspec --allow-warnings"
47
48
  },
48
49
  "dependencies": {
49
50
  "@capacitor/synapse": "^1.0.4"