MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / File

Class File

packages/core/file-system/index.ts:306–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304const ios = new iOS();
305
306export class File extends FileSystemEntity {
307 public static get ios() {
308 return ios;
309 }
310
311 public static get android() {
312 return ad;
313 }
314
315 public static fromPath(path: string, copy: boolean = false) {
316 const onError = function (error) {
317 throw error;
318 };
319
320 if (__ANDROID__ && copy) {
321 if (path.startsWith('content:')) {
322 const fileInfo = getFileAccess().getFile(path, onError);
323 // falls back to creating a temp file without a known extension.
324 if (!fileInfo) {
325 const tempFile = `${knownFolders.temp().path}/${java.util.UUID.randomUUID().toString()}`;
326 org.nativescript.widgets.Async.File.copySync(path, tempFile, getNativeApp<android.app.Application>().getApplicationContext());
327 path = tempFile;
328 } else {
329 const ext = fileInfo.extension;
330 const name = `${fileInfo.name.replace(`.${ext}`, '')}.${ext}`;
331 const tempFile = `${knownFolders.temp().path}/${name}`;
332 getFileAccess().copySync(path, tempFile);
333 path = tempFile;
334 }
335 }
336 }
337
338 const fileInfo = getFileAccess().getFile(path, onError);
339 if (!fileInfo) {
340 return undefined;
341 }
342
343 return createFile(fileInfo);
344 }
345
346 public static exists(path: string): boolean {
347 return getFileAccess().fileExists(path);
348 }
349
350 get extension(): string {
351 return this._extension;
352 }
353
354 get isLocked(): boolean {
355 // !! is a boolean conversion/cast, handling undefined as well
356 return !!this._locked;
357 }
358
359 get size(): number {
360 return getFileAccess().getFileSize(this.path);
361 }
362
363 public append(content: any): Promise<void> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected