Skip to content

Commit

Permalink
Ready for first release
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddoxkkm committed Mar 27, 2018
1 parent c8b0bf3 commit 0450366
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 2 deletions.
44 changes: 44 additions & 0 deletions fileSystem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const fs = require('fs');
const fsextra = require('fs-extra');
const dvpl = require('./dvpl_convert.js');

async function recursionOnFolders (passFun, dir, outDir){
let fileCount = 0;
let dirList = await fsextra.readdir(dir);
dirList.map(async x => {
if(fs.statSync(`${dir}\\${x}`).isDirectory()){
fsextra.mkdirs(`${outDir}\\${x}`);
fileCount += await recursionOnFolders(passFun,`${dir}\\${x}`,`${outDir}\\${x}`);
}
else {
passFun(`${dir}\\${x}`,`${outDir}\\${x}`);
fileCount += 1;
}
});
return fileCount
}

async function compress (fileIn, fileOut){
let fileData = await fsextra.readFile(fileIn);
try{
fsextra.writeFile(fileOut + '.dvpl', dvpl.compressDVPl(fileData));
console.log(`File ${fileIn} has been successfully compressed into ${fileOut}.dvpl`)
} catch (err){
console.log("\x1b[41m%\x1b[0m", `File ${fileIn} Failed to convert due to ${err}`)
}
}

async function decompress (fileIn, fileOut){
let fileData = await fsextra.readFile(fileIn);
try{
fsextra.writeFile(fileOut.replace(".dvpl",""), dvpl.decompressDVPL(fileData));
console.log(`File ${fileIn} has been successfully decompressed into ${fileOut.replace(".dvpl","")}`)
}
catch(err){
console.log("\x1b[41m%\x1b[0m", `File ${fileIn} Failed to convert due to ${err}`)
}
}

exports.recursionOnFolders = recursionOnFolders;
exports.compress = compress;
exports.decompress = decompress;
3 changes: 3 additions & 0 deletions fromDVPL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const reFS = require('./fileSystem.js');

reFS.recursionOnFolders(reFS.decompress(),'./fromDVPL','output_fromDVPL');
28 changes: 28 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "dvpl_convert.js",
"dependencies": {
"crc": "^3.5.0",
"fs-extra": "^5.0.0",
"lz4": "^0.5.3"
},
"devDependencies": {},
Expand Down
15 changes: 13 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@ This converter aims to be able to directly convert between .dvpl and standard no
there are a few things that need to be addressed:

- [x] there are some unidentified headers and tail data in both lz4 file and dvpl file. will need to figure a bit more about them
- [ ] setup usual scripts so it can be used to pack and unpack large directories.
- [x] setup usual scripts so it can be used to pack and unpack large directories.
- [ ] Build a GUI interface to convert between the two without the need of Node.js and dependencies installed (Electron might be used)
- [ ] improve it so it can also perform conversion on zipped files.


## Set up environment for conversion

- Install Node.js for your environment (https://nodejs.org/en/), download the Recommended version
- Setup environment for Node-gyp (https://github.com/nodejs/node-gyp) scroll down to "Installation"
- clone this repo
- in this directory execute the command `npm install`
- Create folders (to place your directories and files into it) named:
- "toDVPL" (files that are going to be converted to `.dvpl` files)
- "fromDVPL" (files that are going to be converted back to non-dvpl files)
- execute the command `node toDVPL` (for compression to dvpl files) or `node fromDVPL` (for decompression to non-dvpl files)
## Things that have been identified:

- DVPL files are non-dvpl files compressed in LZ4_HC format, With custom footer data.
Expand All @@ -33,4 +44,4 @@ All Reference File have been moved to `DVPLConverter_Demo` branch.
## libraries used

- `lz4` a port of the LZ4 compression algorithm (https://github.com/pierrec/node-lz4)
- `buffer-crc32` for crc32 calculation included in footer for DVPL (might change to another library in future)
- `crc32` for crc32 calculation included in footer for DVPL (might change to another library in future)
3 changes: 3 additions & 0 deletions toDVPL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const reFS = require('./fileSystem.js');

reFS.recursionOnFolders(reFS.compress,'./toDVPL','output_toDVPL');

0 comments on commit 0450366

Please sign in to comment.