forked from haxi0/Derootifier
-
Notifications
You must be signed in to change notification settings - Fork 11
/
AppFileShare.m
58 lines (47 loc) · 1.73 KB
/
AppFileShare.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// AppFileShare.m
// Sileo
//
// Created by admin on 7/5/2024.
// Copyright © 2024 Sileo Team. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface LSApplicationProxy : NSObject
- (id)correspondingApplicationRecord;
+ (id)applicationProxyForIdentifier:(id)arg1;
- (id)localizedNameForContext:(id)arg1;
- (NSURL *)bundleURL;
- (NSURL *)containerURL;
- (NSURL *)dataContainerURL;
- (NSString *)bundleExecutable;
- (NSString *)bundleIdentifier;
- (NSString *)vendorName;
- (NSString *)teamID;
- (NSString *)applicationType;
- (NSSet *)claimedURLSchemes;
- (BOOL)isDeletable;
- (NSDictionary*)environmentVariables;
@property (nonatomic,readonly) NSString * applicationIdentifier;
@property (nonatomic,readonly) NSDictionary *groupContainerURLs;
@end
@interface LSApplicationWorkspace : NSObject
+ (id)defaultWorkspace;
-(id)operationToOpenResource:(id)arg1 usingApplication:(id)arg2 userInfo:(id)arg3;
@end
BOOL IsAppAvailable(NSString* bundleId)
{
LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:bundleId];
return app && app.bundleExecutable;
}
BOOL ShareFileToApp(NSString* bundleId, NSString* filePath)
{
LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:bundleId];
if(!app || !app.bundleExecutable) return NO;
NSOperation *op = [[LSApplicationWorkspace defaultWorkspace]
operationToOpenResource:[NSURL fileURLWithPath:filePath]
usingApplication:[app applicationIdentifier] userInfo:nil];
if(!op) return NO;
[op start];
NSLog(@"SileoLog: ShareFileToApp %@ %d %d %d %@", [app applicationIdentifier], [op isExecuting], [op isFinished], [op isConcurrent], filePath);
return YES;
}