SWFファイル内の画像を表示/書き出しするGUIツール
修订版 | 024ab5d139ef04112f3b2745e3755a0f08e69063 (tree) |
---|---|
时间 | 2016-09-30 00:09:35 |
作者 | masakih <masakih@user...> |
Commiter | masakih |
一時フォルダを管理するクラスを追加
@@ -18,6 +18,7 @@ | ||
18 | 18 | F42ADB4C1D9AA56000407165 /* KanColleGraphicDivider in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB4B1D9AA56000407165 /* KanColleGraphicDivider */; }; |
19 | 19 | F42ADB4F1D9AC37600407165 /* NSString-extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB4E1D9AC37600407165 /* NSString-extensions.m */; }; |
20 | 20 | F42ADB651D9BFDED00407165 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB631D9BFDED00407165 /* Localizable.strings */; }; |
21 | + F42ADB681D9D5F1300407165 /* HMTemporaryDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB671D9D5F1300407165 /* HMTemporaryDirectory.m */; }; | |
21 | 22 | /* End PBXBuildFile section */ |
22 | 23 | |
23 | 24 | /* Begin PBXContainerItemProxy section */ |
@@ -60,6 +61,8 @@ | ||
60 | 61 | F42ADB581D9BFCD100407165 /* KanColleGraphicDivider.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = KanColleGraphicDivider.xcodeproj; path = KanColleGraphicDivider/KanColleGraphicDivider.xcodeproj; sourceTree = "<group>"; }; |
61 | 62 | F42ADB611D9BFD5600407165 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text; name = ja; path = ja.lproj/Localizable.strings.sed; sourceTree = "<group>"; }; |
62 | 63 | F42ADB641D9BFDED00407165 /* ja */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; }; |
64 | + F42ADB661D9D5F1300407165 /* HMTemporaryDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMTemporaryDirectory.h; sourceTree = "<group>"; }; | |
65 | + F42ADB671D9D5F1300407165 /* HMTemporaryDirectory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMTemporaryDirectory.m; sourceTree = "<group>"; }; | |
63 | 66 | /* End PBXFileReference section */ |
64 | 67 | |
65 | 68 | /* Begin PBXFrameworksBuildPhase section */ |
@@ -102,6 +105,8 @@ | ||
102 | 105 | F42ADB2E1D9A91D400407165 /* HMSwfDocument.xib */, |
103 | 106 | F42ADB431D9A96ED00407165 /* HMSwfImage.h */, |
104 | 107 | F42ADB441D9A96ED00407165 /* HMSwfImage.m */, |
108 | + F42ADB661D9D5F1300407165 /* HMTemporaryDirectory.h */, | |
109 | + F42ADB671D9D5F1300407165 /* HMTemporaryDirectory.m */, | |
105 | 110 | F42ADB4D1D9AC37600407165 /* NSString-extensions.h */, |
106 | 111 | F42ADB4E1D9AC37600407165 /* NSString-extensions.m */, |
107 | 112 | F42ADB311D9A91D400407165 /* Assets.xcassets */, |
@@ -233,6 +238,7 @@ | ||
233 | 238 | files = ( |
234 | 239 | F42ADB2D1D9A91D300407165 /* HMSwfDocument.m in Sources */, |
235 | 240 | F42ADB2A1D9A91D300407165 /* main.m in Sources */, |
241 | + F42ADB681D9D5F1300407165 /* HMTemporaryDirectory.m in Sources */, | |
236 | 242 | F42ADB4F1D9AC37600407165 /* NSString-extensions.m in Sources */, |
237 | 243 | F42ADB271D9A91D300407165 /* AppDelegate.m in Sources */, |
238 | 244 | F42ADB451D9A96ED00407165 /* HMSwfImage.m in Sources */, |
@@ -0,0 +1,17 @@ | ||
1 | +// | |
2 | +// HMTemporaryDirectory.h | |
3 | +// KoreNoKaraSu | |
4 | +// | |
5 | +// Created by Hori,Masaki on 2016/09/29. | |
6 | +// Copyright © 2016年 Hori,Masaki. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +#import <Foundation/Foundation.h> | |
10 | + | |
11 | +@interface HMTemporaryDirectory : NSObject | |
12 | + | |
13 | ++ (instancetype)temporaryDirectoryWithName:(NSString *)name; | |
14 | + | |
15 | +@property (readonly) NSURL *URL; | |
16 | +@property (readonly) NSString *fullpath; | |
17 | +@end |
@@ -0,0 +1,85 @@ | ||
1 | +// | |
2 | +// HMTemporaryDirectory.m | |
3 | +// KoreNoKaraSu | |
4 | +// | |
5 | +// Created by Hori,Masaki on 2016/09/29. | |
6 | +// Copyright © 2016年 Hori,Masaki. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +#import "HMTemporaryDirectory.h" | |
10 | + | |
11 | +@interface HMTemporaryDirectory () | |
12 | +@property (readwrite, strong) NSString *fullpath; | |
13 | +@end | |
14 | + | |
15 | +@implementation HMTemporaryDirectory | |
16 | + | |
17 | ++ (instancetype)temporaryDirectoryWithName:(NSString *)name | |
18 | +{ | |
19 | + return [[self alloc] initWithName:name]; | |
20 | +} | |
21 | +- (instancetype)initWithName:(NSString *)name | |
22 | +{ | |
23 | + self = [super init]; | |
24 | + if(self) { | |
25 | + NSBundle *mainBundle = [NSBundle mainBundle]; | |
26 | + NSString *identifier = mainBundle.bundleIdentifier; | |
27 | + NSString *tempDir = nil; | |
28 | + if(identifier) { | |
29 | + tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:identifier]; | |
30 | + } else { | |
31 | + tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:@"KoreNoKaraSu"]; | |
32 | + } | |
33 | + | |
34 | + _fullpath = [tempDir stringByAppendingPathComponent:name]; | |
35 | + | |
36 | + NSFileManager *fm = [NSFileManager defaultManager]; | |
37 | + BOOL isOK = NO; | |
38 | + NSError *error = nil; | |
39 | + | |
40 | + isOK = [fm createDirectoryAtPath:tempDir | |
41 | + withIntermediateDirectories:YES | |
42 | + attributes:nil | |
43 | + error:&error]; | |
44 | + if(!isOK) { | |
45 | + if(error) { | |
46 | + NSLog(@"%@", error); | |
47 | + } | |
48 | + NSLog(@"Can not create directory. %@", tempDir); | |
49 | + return nil; | |
50 | + } | |
51 | + | |
52 | + error = nil; | |
53 | + isOK = [fm createDirectoryAtPath:_fullpath | |
54 | + withIntermediateDirectories:YES | |
55 | + attributes:nil | |
56 | + error:&error]; | |
57 | + if(!isOK) { | |
58 | + if(error) { | |
59 | + NSLog(@"%@", error); | |
60 | + } | |
61 | + NSLog(@"Can not create directory. %@", _fullpath); | |
62 | + return nil; | |
63 | + } | |
64 | + } | |
65 | + | |
66 | + return self; | |
67 | +} | |
68 | +- (void)dealloc | |
69 | +{ | |
70 | + NSFileManager *fm = [NSFileManager defaultManager]; | |
71 | + NSError *error = nil; | |
72 | + if(![fm removeItemAtURL:self.URL | |
73 | + error:&error]) { | |
74 | + if(error) { | |
75 | + NSLog(@"can not remove item %@: reason %@", self.URL, error); | |
76 | + } else { | |
77 | + NSLog(@"can not remove item %@", self.URL); | |
78 | + } | |
79 | + } | |
80 | +} | |
81 | +- (NSURL *)URL | |
82 | +{ | |
83 | + return [NSURL fileURLWithPath:self.fullpath]; | |
84 | +} | |
85 | +@end |