• 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ファイル内の画像を表示/書き出しするGUIツール


Commit MetaInfo

修订版024ab5d139ef04112f3b2745e3755a0f08e69063 (tree)
时间2016-09-30 00:09:35
作者masakih <masakih@user...>
Commitermasakih

Log Message

一時フォルダを管理するクラスを追加

更改概述

差异

--- a/KoreNoKaraSu.xcodeproj/project.pbxproj
+++ b/KoreNoKaraSu.xcodeproj/project.pbxproj
@@ -18,6 +18,7 @@
1818 F42ADB4C1D9AA56000407165 /* KanColleGraphicDivider in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB4B1D9AA56000407165 /* KanColleGraphicDivider */; };
1919 F42ADB4F1D9AC37600407165 /* NSString-extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB4E1D9AC37600407165 /* NSString-extensions.m */; };
2020 F42ADB651D9BFDED00407165 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB631D9BFDED00407165 /* Localizable.strings */; };
21+ F42ADB681D9D5F1300407165 /* HMTemporaryDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB671D9D5F1300407165 /* HMTemporaryDirectory.m */; };
2122 /* End PBXBuildFile section */
2223
2324 /* Begin PBXContainerItemProxy section */
@@ -60,6 +61,8 @@
6061 F42ADB581D9BFCD100407165 /* KanColleGraphicDivider.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = KanColleGraphicDivider.xcodeproj; path = KanColleGraphicDivider/KanColleGraphicDivider.xcodeproj; sourceTree = "<group>"; };
6162 F42ADB611D9BFD5600407165 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text; name = ja; path = ja.lproj/Localizable.strings.sed; sourceTree = "<group>"; };
6263 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>"; };
6366 /* End PBXFileReference section */
6467
6568 /* Begin PBXFrameworksBuildPhase section */
@@ -102,6 +105,8 @@
102105 F42ADB2E1D9A91D400407165 /* HMSwfDocument.xib */,
103106 F42ADB431D9A96ED00407165 /* HMSwfImage.h */,
104107 F42ADB441D9A96ED00407165 /* HMSwfImage.m */,
108+ F42ADB661D9D5F1300407165 /* HMTemporaryDirectory.h */,
109+ F42ADB671D9D5F1300407165 /* HMTemporaryDirectory.m */,
105110 F42ADB4D1D9AC37600407165 /* NSString-extensions.h */,
106111 F42ADB4E1D9AC37600407165 /* NSString-extensions.m */,
107112 F42ADB311D9A91D400407165 /* Assets.xcassets */,
@@ -233,6 +238,7 @@
233238 files = (
234239 F42ADB2D1D9A91D300407165 /* HMSwfDocument.m in Sources */,
235240 F42ADB2A1D9A91D300407165 /* main.m in Sources */,
241+ F42ADB681D9D5F1300407165 /* HMTemporaryDirectory.m in Sources */,
236242 F42ADB4F1D9AC37600407165 /* NSString-extensions.m in Sources */,
237243 F42ADB271D9A91D300407165 /* AppDelegate.m in Sources */,
238244 F42ADB451D9A96ED00407165 /* HMSwfImage.m in Sources */,
--- /dev/null
+++ b/KoreNoKaraSu/HMTemporaryDirectory.h
@@ -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
--- /dev/null
+++ b/KoreNoKaraSu/HMTemporaryDirectory.m
@@ -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