• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

swfから画像を抽出するコマンドラインアプリケーション


Commit MetaInfo

修订版011485a879d08e456fdaa26dc2aada2a9269fa3f (tree)
时间2018-05-23 00:43:36
作者masakih <masakih@user...>
Commitermasakih

Log Message

f オプションを追加

f, force オプションを設定すると出力ファイルが存在しても上書きする。設定されていなければ、何もしない。

更改概述

差异

--- a/KanColleGraphicDivider/ImageStore.m
+++ b/KanColleGraphicDivider/ImageStore.m
@@ -39,6 +39,13 @@
3939 path = [self.information.outputDir stringByAppendingPathComponent:path];
4040 NSURL *url = [NSURL fileURLWithPath:path];
4141
42+ if( !self.information.forceOverWrite && [url checkResourceIsReachableAndReturnError:nil] ) {
43+
44+ fprintf(stderr, "%s is already exist.\n", url.path.UTF8String);
45+
46+ return;
47+ }
48+
4249 [decoder.decodedData writeToURL:url atomically:YES];
4350 }
4451
--- a/KanColleGraphicDivider/Information.h
+++ b/KanColleGraphicDivider/Information.h
@@ -16,6 +16,7 @@
1616 @property (copy) NSString *outputDir;
1717 @property (copy) NSString *filename;
1818 @property (copy) NSArray *charctorIds;
19+@property BOOL forceOverWrite;
1920
2021 - (BOOL)skipCharactorID:(UInt16) chractorid;
2122
--- a/KanColleGraphicDivider/main.m
+++ b/KanColleGraphicDivider/main.m
@@ -33,6 +33,8 @@ static void usage(int exitVal, FILE *fp) {
3333 fprintf(fp, "\textracted images output to output-directory.\n");
3434 fprintf(fp, " -v, --version\n");
3535 fprintf(fp, "\toutput version information and exit.\n");
36+ fprintf(fp, " -f, --force\n");
37+ fprintf(fp, "\tif set, force orver write outputfile.\n");
3638 fprintf(fp, " -h, --help\n");
3739 fprintf(fp, "\tdisplay this help and text.\n");
3840
@@ -48,6 +50,7 @@ int main(int argc, char * const *argv) {
4850
4951 NSString *outputDir = nil;
5052 NSArray *charactorIds = nil;
53+ BOOL forceOverwrite = NO;
5154
5255 @autoreleasepool {
5356 // 引数の処理
@@ -57,10 +60,11 @@ int main(int argc, char * const *argv) {
5760
5861 toolName = toolNameStr(argv[0]);
5962
60-#define SHORTOPTS "ho:vc:"
63+#define SHORTOPTS "fho:vc:"
6164 static struct option longopts[] = {
6265 {"output", required_argument, NULL, 'o'},
6366 {"charactorid", required_argument, NULL, 'c'},
67+ {"force", no_argument, NULL, 'f'},
6468 {"version", no_argument, NULL, 'v'},
6569 {"help", no_argument, NULL, 'h'},
6670 {NULL, 0, NULL, 0}
@@ -75,6 +79,9 @@ int main(int argc, char * const *argv) {
7579 case 'c':
7680 charactorid = optarg;
7781 break;
82+ case 'f':
83+ forceOverwrite = YES;
84+ break;
7885 case 'h':
7986 usage(EXIT_SUCCESS, stdout);
8087 break;
@@ -133,6 +140,7 @@ int main(int argc, char * const *argv) {
133140 info.outputDir = outputDir;
134141 info.charctorIds = charactorIds;
135142 info.filename = [[NSString alloc] initWithUTF8String:filename];
143+ info.forceOverWrite = forceOverwrite;
136144
137145 dispatch_group_async(group, queue, ^{
138146