├── README.md
├── icloudpurge.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
└── icloudpurge
└── main.m
/README.md:
--------------------------------------------------------------------------------
1 | # icloudpurge
2 | Commandline utility to manually purge local copies of files on iCloud Drive.
3 |
4 | ```Usage: icloudpurge /path/to/purge```
--------------------------------------------------------------------------------
/icloudpurge.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/icloudpurge/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // icloudpurge
4 | //
5 | // Created by Steven Troughton-Smith on 24/01/2017.
6 | // Copyright © 2017 High Caffeine Content. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | void usage()
12 | {
13 | printf("Usage: icloudpurge [-f] /path/to/purge\n\n");
14 | }
15 |
16 | int main(int argc, const char * argv[]) {
17 | @autoreleasepool {
18 |
19 | char s[20];
20 |
21 | if (argc > 1)
22 | {
23 | int pathIdx = 1;
24 | BOOL confirm = YES;
25 |
26 | if (argc > 2)
27 | {
28 | pathIdx = 2;
29 | confirm = NO;
30 | }
31 |
32 | NSString *destpath = [[NSString alloc] initWithUTF8String:argv[pathIdx]];
33 |
34 | if ([[NSFileManager defaultManager] fileExistsAtPath:destpath isDirectory:nil])
35 | {
36 | if (confirm)
37 | {
38 | printf("Really purge %s? y/N ", [destpath UTF8String]);
39 | scanf("%c", s);
40 |
41 | if (s[0] != 'y')
42 | {
43 | return -1;
44 | }
45 | }
46 |
47 | printf("Purging %s…\n", [destpath UTF8String]);
48 | NSError *error = nil;
49 |
50 | [[NSFileManager defaultManager] evictUbiquitousItemAtURL:[NSURL fileURLWithPath:destpath] error:&error];
51 |
52 | if (error)
53 | {
54 | printf("%s", [[error localizedDescription] UTF8String]);
55 | return -1;
56 | }
57 |
58 | return 0;
59 | }
60 | else
61 | {
62 | printf("Path %s not found.\n", [destpath UTF8String]);
63 | return -1;
64 | }
65 | }
66 | }
67 |
68 | usage();
69 |
70 | return -1;
71 | }
72 |
--------------------------------------------------------------------------------
/icloudpurge.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | B028253E1E3756BB00F1898B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B028253D1E3756BB00F1898B /* main.m */; };
11 | /* End PBXBuildFile section */
12 |
13 | /* Begin PBXCopyFilesBuildPhase section */
14 | B02825381E3756BB00F1898B /* CopyFiles */ = {
15 | isa = PBXCopyFilesBuildPhase;
16 | buildActionMask = 2147483647;
17 | dstPath = /usr/share/man/man1/;
18 | dstSubfolderSpec = 0;
19 | files = (
20 | );
21 | runOnlyForDeploymentPostprocessing = 1;
22 | };
23 | /* End PBXCopyFilesBuildPhase section */
24 |
25 | /* Begin PBXFileReference section */
26 | B028253A1E3756BB00F1898B /* icloudpurge */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = icloudpurge; sourceTree = BUILT_PRODUCTS_DIR; };
27 | B028253D1E3756BB00F1898B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
28 | /* End PBXFileReference section */
29 |
30 | /* Begin PBXFrameworksBuildPhase section */
31 | B02825371E3756BB00F1898B /* Frameworks */ = {
32 | isa = PBXFrameworksBuildPhase;
33 | buildActionMask = 2147483647;
34 | files = (
35 | );
36 | runOnlyForDeploymentPostprocessing = 0;
37 | };
38 | /* End PBXFrameworksBuildPhase section */
39 |
40 | /* Begin PBXGroup section */
41 | B02825311E3756BB00F1898B = {
42 | isa = PBXGroup;
43 | children = (
44 | B028253C1E3756BB00F1898B /* icloudpurge */,
45 | B028253B1E3756BB00F1898B /* Products */,
46 | B02825441E3756C800F1898B /* Frameworks */,
47 | );
48 | sourceTree = "";
49 | };
50 | B028253B1E3756BB00F1898B /* Products */ = {
51 | isa = PBXGroup;
52 | children = (
53 | B028253A1E3756BB00F1898B /* icloudpurge */,
54 | );
55 | name = Products;
56 | sourceTree = "";
57 | };
58 | B028253C1E3756BB00F1898B /* icloudpurge */ = {
59 | isa = PBXGroup;
60 | children = (
61 | B028253D1E3756BB00F1898B /* main.m */,
62 | );
63 | path = icloudpurge;
64 | sourceTree = "";
65 | };
66 | B02825441E3756C800F1898B /* Frameworks */ = {
67 | isa = PBXGroup;
68 | children = (
69 | );
70 | name = Frameworks;
71 | sourceTree = "";
72 | };
73 | /* End PBXGroup section */
74 |
75 | /* Begin PBXNativeTarget section */
76 | B02825391E3756BB00F1898B /* icloudpurge */ = {
77 | isa = PBXNativeTarget;
78 | buildConfigurationList = B02825411E3756BB00F1898B /* Build configuration list for PBXNativeTarget "icloudpurge" */;
79 | buildPhases = (
80 | B02825361E3756BB00F1898B /* Sources */,
81 | B02825371E3756BB00F1898B /* Frameworks */,
82 | B02825381E3756BB00F1898B /* CopyFiles */,
83 | );
84 | buildRules = (
85 | );
86 | dependencies = (
87 | );
88 | name = icloudpurge;
89 | productName = icloudpurge;
90 | productReference = B028253A1E3756BB00F1898B /* icloudpurge */;
91 | productType = "com.apple.product-type.tool";
92 | };
93 | /* End PBXNativeTarget section */
94 |
95 | /* Begin PBXProject section */
96 | B02825321E3756BB00F1898B /* Project object */ = {
97 | isa = PBXProject;
98 | attributes = {
99 | LastUpgradeCheck = 0820;
100 | ORGANIZATIONNAME = "High Caffeine Content";
101 | TargetAttributes = {
102 | B02825391E3756BB00F1898B = {
103 | CreatedOnToolsVersion = 8.2.1;
104 | DevelopmentTeam = 2ZDN69KUUV;
105 | ProvisioningStyle = Automatic;
106 | };
107 | };
108 | };
109 | buildConfigurationList = B02825351E3756BB00F1898B /* Build configuration list for PBXProject "icloudpurge" */;
110 | compatibilityVersion = "Xcode 3.2";
111 | developmentRegion = English;
112 | hasScannedForEncodings = 0;
113 | knownRegions = (
114 | en,
115 | );
116 | mainGroup = B02825311E3756BB00F1898B;
117 | productRefGroup = B028253B1E3756BB00F1898B /* Products */;
118 | projectDirPath = "";
119 | projectRoot = "";
120 | targets = (
121 | B02825391E3756BB00F1898B /* icloudpurge */,
122 | );
123 | };
124 | /* End PBXProject section */
125 |
126 | /* Begin PBXSourcesBuildPhase section */
127 | B02825361E3756BB00F1898B /* Sources */ = {
128 | isa = PBXSourcesBuildPhase;
129 | buildActionMask = 2147483647;
130 | files = (
131 | B028253E1E3756BB00F1898B /* main.m in Sources */,
132 | );
133 | runOnlyForDeploymentPostprocessing = 0;
134 | };
135 | /* End PBXSourcesBuildPhase section */
136 |
137 | /* Begin XCBuildConfiguration section */
138 | B028253F1E3756BB00F1898B /* Debug */ = {
139 | isa = XCBuildConfiguration;
140 | buildSettings = {
141 | ALWAYS_SEARCH_USER_PATHS = NO;
142 | CLANG_ANALYZER_NONNULL = YES;
143 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
144 | CLANG_CXX_LIBRARY = "libc++";
145 | CLANG_ENABLE_MODULES = YES;
146 | CLANG_ENABLE_OBJC_ARC = YES;
147 | CLANG_WARN_BOOL_CONVERSION = YES;
148 | CLANG_WARN_CONSTANT_CONVERSION = YES;
149 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
150 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
151 | CLANG_WARN_EMPTY_BODY = YES;
152 | CLANG_WARN_ENUM_CONVERSION = YES;
153 | CLANG_WARN_INFINITE_RECURSION = YES;
154 | CLANG_WARN_INT_CONVERSION = YES;
155 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
156 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
157 | CLANG_WARN_UNREACHABLE_CODE = YES;
158 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
159 | CODE_SIGN_IDENTITY = "-";
160 | COPY_PHASE_STRIP = NO;
161 | DEBUG_INFORMATION_FORMAT = dwarf;
162 | ENABLE_STRICT_OBJC_MSGSEND = YES;
163 | ENABLE_TESTABILITY = YES;
164 | GCC_C_LANGUAGE_STANDARD = gnu99;
165 | GCC_DYNAMIC_NO_PIC = NO;
166 | GCC_NO_COMMON_BLOCKS = YES;
167 | GCC_OPTIMIZATION_LEVEL = 0;
168 | GCC_PREPROCESSOR_DEFINITIONS = (
169 | "DEBUG=1",
170 | "$(inherited)",
171 | );
172 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
173 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
174 | GCC_WARN_UNDECLARED_SELECTOR = YES;
175 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
176 | GCC_WARN_UNUSED_FUNCTION = YES;
177 | GCC_WARN_UNUSED_VARIABLE = YES;
178 | MACOSX_DEPLOYMENT_TARGET = 10.12;
179 | MTL_ENABLE_DEBUG_INFO = YES;
180 | ONLY_ACTIVE_ARCH = YES;
181 | SDKROOT = macosx;
182 | };
183 | name = Debug;
184 | };
185 | B02825401E3756BB00F1898B /* Release */ = {
186 | isa = XCBuildConfiguration;
187 | buildSettings = {
188 | ALWAYS_SEARCH_USER_PATHS = NO;
189 | CLANG_ANALYZER_NONNULL = YES;
190 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
191 | CLANG_CXX_LIBRARY = "libc++";
192 | CLANG_ENABLE_MODULES = YES;
193 | CLANG_ENABLE_OBJC_ARC = YES;
194 | CLANG_WARN_BOOL_CONVERSION = YES;
195 | CLANG_WARN_CONSTANT_CONVERSION = YES;
196 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
197 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
198 | CLANG_WARN_EMPTY_BODY = YES;
199 | CLANG_WARN_ENUM_CONVERSION = YES;
200 | CLANG_WARN_INFINITE_RECURSION = YES;
201 | CLANG_WARN_INT_CONVERSION = YES;
202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
203 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
204 | CLANG_WARN_UNREACHABLE_CODE = YES;
205 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
206 | CODE_SIGN_IDENTITY = "-";
207 | COPY_PHASE_STRIP = NO;
208 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
209 | ENABLE_NS_ASSERTIONS = NO;
210 | ENABLE_STRICT_OBJC_MSGSEND = YES;
211 | GCC_C_LANGUAGE_STANDARD = gnu99;
212 | GCC_NO_COMMON_BLOCKS = YES;
213 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
214 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
215 | GCC_WARN_UNDECLARED_SELECTOR = YES;
216 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
217 | GCC_WARN_UNUSED_FUNCTION = YES;
218 | GCC_WARN_UNUSED_VARIABLE = YES;
219 | MACOSX_DEPLOYMENT_TARGET = 10.12;
220 | MTL_ENABLE_DEBUG_INFO = NO;
221 | SDKROOT = macosx;
222 | };
223 | name = Release;
224 | };
225 | B02825421E3756BB00F1898B /* Debug */ = {
226 | isa = XCBuildConfiguration;
227 | buildSettings = {
228 | DEVELOPMENT_TEAM = 2ZDN69KUUV;
229 | FRAMEWORK_SEARCH_PATHS = (
230 | "$(inherited)",
231 | "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
232 | );
233 | PRODUCT_NAME = "$(TARGET_NAME)";
234 | };
235 | name = Debug;
236 | };
237 | B02825431E3756BB00F1898B /* Release */ = {
238 | isa = XCBuildConfiguration;
239 | buildSettings = {
240 | DEVELOPMENT_TEAM = 2ZDN69KUUV;
241 | FRAMEWORK_SEARCH_PATHS = (
242 | "$(inherited)",
243 | "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
244 | );
245 | PRODUCT_NAME = "$(TARGET_NAME)";
246 | };
247 | name = Release;
248 | };
249 | /* End XCBuildConfiguration section */
250 |
251 | /* Begin XCConfigurationList section */
252 | B02825351E3756BB00F1898B /* Build configuration list for PBXProject "icloudpurge" */ = {
253 | isa = XCConfigurationList;
254 | buildConfigurations = (
255 | B028253F1E3756BB00F1898B /* Debug */,
256 | B02825401E3756BB00F1898B /* Release */,
257 | );
258 | defaultConfigurationIsVisible = 0;
259 | defaultConfigurationName = Release;
260 | };
261 | B02825411E3756BB00F1898B /* Build configuration list for PBXNativeTarget "icloudpurge" */ = {
262 | isa = XCConfigurationList;
263 | buildConfigurations = (
264 | B02825421E3756BB00F1898B /* Debug */,
265 | B02825431E3756BB00F1898B /* Release */,
266 | );
267 | defaultConfigurationIsVisible = 0;
268 | };
269 | /* End XCConfigurationList section */
270 | };
271 | rootObject = B02825321E3756BB00F1898B /* Project object */;
272 | }
273 |
--------------------------------------------------------------------------------