Skip to content

Commit

Permalink
Implemented directory expansion support for --create and improved doc…
Browse files Browse the repository at this point in the history
…umentation. This closes #119.
  • Loading branch information
nicoboss committed Sep 7, 2022
1 parent 728654d commit cfe2cbe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ usage: nsz.py [-h] [-C] [-D] [-l LEVEL] [-B] [-S] [-s BS] [-V] [-p] [-P]
positional arguments:
file
optional arguments:
options:
-h, --help show this help message and exit
-C Compress NSP/XCI
-D Decompress NSZ/XCZ/NCZ
Expand Down Expand Up @@ -141,7 +141,8 @@ optional arguments:
Removes every old version as long there is a newer one
of the same titleID.
-c CREATE, --create CREATE
create / pack a NSP
Inverse of --extract. Repacks files/folders to an NSP.
Example: --create out.nsp .\in
```

## Few Usage Examples
Expand Down
20 changes: 11 additions & 9 deletions nsz/Fs/Nsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import shutil
from nsz.nut import Titles
from nsz.nut.Titles import Title
from nsz.PathTools import *

MEDIA_SIZE = 0x200

Expand Down Expand Up @@ -387,15 +388,16 @@ def pack(self, files):
t.update(len(hd))

done = 0
for file in files:
Print.info('\t\tAppending %s...' % os.path.basename(file))
with open(file, 'rb') as inf:
while True:
buf = inf.read(4096)
if not buf:
break
outf.write(buf)
t.update(len(buf))
for f_str in files:
for filePath in expandFiles(Path(f_str)):
Print.info('\t\tAppending %s...' % os.path.basename(filePath))
with open(filePath, 'rb') as inf:
while True:
buf = inf.read(4096)
if not buf:
break
outf.write(buf)
t.update(len(buf))
t.close()

Print.info('\t\tRepacked to %s!' % outf.name)
Expand Down
2 changes: 1 addition & 1 deletion nsz/ParseArguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def parse():
parser.add_argument('--undupe-whitelist', type=str, default="", help='Regex specifying which dublicates should under no circumstances be deleted. Example: "^.*\.(nsz|xcz)$"')
parser.add_argument('--undupe-blacklist', type=str, default="", help='Regex specifying which files should always be deleted - even if they are not even a dublicate! Be careful! Example: "^.*\.(nsp|xci)$"')
parser.add_argument('--undupe-old-versions',action="store_true", default=False, help='Removes every old version as long there is a newer one of the same titleID.')
parser.add_argument('-c', '--create', help='create / pack a NSP')
parser.add_argument('-c', '--create', help='Inverse of --extract. Repacks files/folders to an NSP. Example: --create out.nsp .\in')

args = parser.parse_args()
return args

0 comments on commit cfe2cbe

Please sign in to comment.