From b4cec07e2d72acaad2ab1e6abc9e49b704a4fc2b Mon Sep 17 00:00:00 2001 From: Sayan Ghosh Date: Tue, 19 May 2020 23:01:23 +0530 Subject: [PATCH] Create folders if deleted --- .../wlfs/largefilesplitter/MainActivity.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/java/wlfs/largefilesplitter/MainActivity.java b/app/src/main/java/wlfs/largefilesplitter/MainActivity.java index c9d24f6..1d35b82 100644 --- a/app/src/main/java/wlfs/largefilesplitter/MainActivity.java +++ b/app/src/main/java/wlfs/largefilesplitter/MainActivity.java @@ -94,6 +94,16 @@ protected void onPreExecute() { protected Exception doInBackground(String... strings) { String path = strings[0]; try { + File split_path = new File(SPLIT_FILE_PATH); + if(!split_path.exists()){ + boolean success = split_path.mkdirs(); + if(!success){ + Toast.makeText(MainActivity.this, + "Unable to create directory to put files in", + Toast.LENGTH_SHORT).show(); + return new Exception(); + } + } int counter = 0; // counts no of megabytes of data read int num = 1; // output file prefix File f = new File(path); @@ -210,6 +220,16 @@ protected void onPreExecute() { protected Exception doInBackground(String... strings) { String path = strings[0]; try { + File join_path = new File(JOIN_FILE_PATH); + if(!join_path.exists()){ + boolean success = join_path.mkdirs(); + if (!success){ + Toast.makeText(MainActivity.this, + "Unable to create directory for output file", + Toast.LENGTH_SHORT).show(); + return new Exception(); + } + } int counter = 1; // counts no of megabytes of data read File[] partfiles = getLFSPartFiles(path); if(partfiles == null || partfiles.length < 1){