博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
copy file
阅读量:5336 次
发布时间:2019-06-15

本文共 3809 字,大约阅读时间需要 12 分钟。

import io,,,,,,,

 

 

from https://pub.dev/packages/large_file_copy

Directory directory = await getApplicationDocumentsDirectory();var dbPath = join(directory.path, "app.db");if (FileSystemEntity.typeSync(dbPath) == FileSystemEntityType.notFound) {  ByteData data = await rootBundle.load("assets/my_db_file.db"); List
bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); await File(dbPath).writeAsBytes(bytes); }

 

var file1 = File(join(tempDir.path, '0/2048.apk')); var newFile = await file1.copy(join(tempDir.path, '4/1.apk'));
import 'package:flutter/material.dart';import 'dart:io';import 'dart:async';import 'package:rxdart/rxdart.dart';import 'package:path_provider/path_provider.dart';import 'package:path/path.dart';import 'package:permission_handler/permission_handler.dart';import 'package:flutter/services.dart';void main() => runApp(MaterialApp(home: MyApp(),));/*1. Copy aria2c executable to ``/mnt/sdcard`` on your device.2. Run Android Terminal Emulator.3. ``mkdir /data/data/jackpal.androidterm/aria2``4. ``cat /mnt/sdcard/aria2c > /data/data/jackpal.androidterm/aria2/aria2c``5. ``chmod 744 /data/data/jackpal.androidterm/aria2/aria2c``6. Add the following commands to the initial command of AndroidTerminal Emulator::export HOME=/data/data/jackpal.androidterm/aria2; cd $HOME7. Exit Android Terminal Emulator.8. Run Android Terminal Emulator again.9. See whether aria2c actually works by invoking ``./aria2c -v``*/class MyApp extends StatelessWidget {  DataBloc bloc;  checkPermission()async{    var per = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage);    if(per!=PermissionStatus.granted){      await PermissionHandler().requestPermissions([PermissionGroup.storage]);    }  }  cp()async{    await checkPermission();    Directory tempDir = await getExternalStorageDirectory();    String workDir = join(tempDir.path, '4');//    var p = await Process.run('mkdir', [workDir]).then((ProcessResult e){//      print(e.stderr);//      print(e.exitCode);//    });    var file1 = await rootBundle.load('assets/aria2c');    var buf = file1.buffer;    File(join(workDir, 'xxx')).writeAsBytesSync(buf.asUint8List());//    var newFile = await file1.copy(join(tempDir.path, '4/1.apk'));    print('done');  }  @override  Widget build(BuildContext context) {    return Scaffold(      appBar: AppBar(title: Text('sss'),),      body: Container(        child: Column(          mainAxisAlignment: MainAxisAlignment.center,          crossAxisAlignment: CrossAxisAlignment.center,          children: 
[ RaisedButton(child: Text('mkdir'),onPressed: (){ cp(); },), RaisedButton(child: Text('delete'),onPressed: (){ },), Container( width: 50,height: 50,child: Image(image: AssetImage('assets/img/a.png',),fit: BoxFit.cover,)),// Container(// width: 50, height: 50,child: Text(' '),decoration: BoxDecoration(// image: DecorationImage(image: AssetImage('assets/img/a.png')),// ),), ], ), ), ); }}class DataBloc { ReplaySubject dataBloc = ReplaySubject();}//void shell(String cmd, List
opts, void onExit(int exitCode))async{// var p = await Process.start(cmd, opts);// p.stdout.pipe(stdout);// stdin.pipe(p.stdin);// p.onExit = (exitCode)async{// await p.kill();// onExit(exitCode);// }//}//void shell(String cmd, List
opts, void onExit(int exitCode)) {// var p = Process.start(cmd, opts);// p.stdout.pipe(stdout); // Process output to stdout.// stdin.pipe(p.stdin); // stdin to process input.// p.onExit = (exitCode) {// p.close();// onExit(exitCode);// };//}

  

转载于:https://www.cnblogs.com/pythonClub/p/10894154.html

你可能感兴趣的文章
360浏览器兼容模式 不能$.post (不是a 连接 onclick的问题!!)
查看>>
Yii安装使用教程(转)
查看>>
Java四种引用包括强引用,软引用,弱引用,虚引用。
查看>>
spring注入Properties
查看>>
微信小程序开发之从相册获取图片 使用相机拍照 本地图片上传
查看>>
【BZOJ-2295】我爱你啊 暴力
查看>>
【BZOJ-1055】玩具取名 区间DP
查看>>
Bit Twiddling Hacks
查看>>
Windwos中的线程同步
查看>>
LeetCode : Reverse Vowels of a String
查看>>
时间戳与日期的相互转换
查看>>
jmeter(五)创建web测试计划
查看>>
python基本数据类型
查看>>
1305: [CQOI2009]dance跳舞 - BZOJ
查看>>
关于TDD的思考
查看>>
Cocos2d-x学习之windows 7 android环境搭建
查看>>
将html代码中的大写标签转换成小写标签
查看>>
jmeter多线程组间的参数传递
查看>>
零散笔记
查看>>
第1章2节《MonkeyRunner源码剖析》概述:边界(原创)
查看>>