objc2_foundation/generated/
NSFileWrapper.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSFileWrapperReadingOptions(pub NSUInteger);
14bitflags::bitflags! {
15 impl NSFileWrapperReadingOptions: NSUInteger {
16 #[doc(alias = "NSFileWrapperReadingImmediate")]
17 const Immediate = 1<<0;
18 #[doc(alias = "NSFileWrapperReadingWithoutMapping")]
19 const WithoutMapping = 1<<1;
20 }
21}
22
23unsafe impl Encode for NSFileWrapperReadingOptions {
24 const ENCODING: Encoding = NSUInteger::ENCODING;
25}
26
27unsafe impl RefEncode for NSFileWrapperReadingOptions {
28 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
29}
30
31#[repr(transparent)]
34#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
35pub struct NSFileWrapperWritingOptions(pub NSUInteger);
36bitflags::bitflags! {
37 impl NSFileWrapperWritingOptions: NSUInteger {
38 #[doc(alias = "NSFileWrapperWritingAtomic")]
39 const Atomic = 1<<0;
40 #[doc(alias = "NSFileWrapperWritingWithNameUpdating")]
41 const WithNameUpdating = 1<<1;
42 }
43}
44
45unsafe impl Encode for NSFileWrapperWritingOptions {
46 const ENCODING: Encoding = NSUInteger::ENCODING;
47}
48
49unsafe impl RefEncode for NSFileWrapperWritingOptions {
50 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
51}
52
53extern_class!(
54 #[unsafe(super(NSObject))]
56 #[derive(Debug, PartialEq, Eq, Hash)]
57 pub struct NSFileWrapper;
58);
59
60#[cfg(feature = "NSObject")]
61unsafe impl NSCoding for NSFileWrapper {}
62
63unsafe impl NSObjectProtocol for NSFileWrapper {}
64
65#[cfg(feature = "NSObject")]
66unsafe impl NSSecureCoding for NSFileWrapper {}
67
68impl NSFileWrapper {
69 extern_methods!(
70 #[cfg(all(feature = "NSError", feature = "NSURL"))]
71 #[unsafe(method(initWithURL:options:error:_))]
72 #[unsafe(method_family = init)]
73 pub unsafe fn initWithURL_options_error(
74 this: Allocated<Self>,
75 url: &NSURL,
76 options: NSFileWrapperReadingOptions,
77 ) -> Result<Retained<Self>, Retained<NSError>>;
78
79 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
80 #[unsafe(method(initDirectoryWithFileWrappers:))]
81 #[unsafe(method_family = init)]
82 pub unsafe fn initDirectoryWithFileWrappers(
83 this: Allocated<Self>,
84 children_by_preferred_name: &NSDictionary<NSString, NSFileWrapper>,
85 ) -> Retained<Self>;
86
87 #[cfg(feature = "NSData")]
88 #[unsafe(method(initRegularFileWithContents:))]
89 #[unsafe(method_family = init)]
90 pub unsafe fn initRegularFileWithContents(
91 this: Allocated<Self>,
92 contents: &NSData,
93 ) -> Retained<Self>;
94
95 #[cfg(feature = "NSURL")]
96 #[unsafe(method(initSymbolicLinkWithDestinationURL:))]
97 #[unsafe(method_family = init)]
98 pub unsafe fn initSymbolicLinkWithDestinationURL(
99 this: Allocated<Self>,
100 url: &NSURL,
101 ) -> Retained<Self>;
102
103 #[cfg(feature = "NSData")]
104 #[unsafe(method(initWithSerializedRepresentation:))]
105 #[unsafe(method_family = init)]
106 pub unsafe fn initWithSerializedRepresentation(
107 this: Allocated<Self>,
108 serialize_representation: &NSData,
109 ) -> Option<Retained<Self>>;
110
111 #[cfg(feature = "NSCoder")]
112 #[unsafe(method(initWithCoder:))]
113 #[unsafe(method_family = init)]
114 pub unsafe fn initWithCoder(
115 this: Allocated<Self>,
116 in_coder: &NSCoder,
117 ) -> Option<Retained<Self>>;
118
119 #[unsafe(method(isDirectory))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn isDirectory(&self) -> bool;
122
123 #[unsafe(method(isRegularFile))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn isRegularFile(&self) -> bool;
126
127 #[unsafe(method(isSymbolicLink))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn isSymbolicLink(&self) -> bool;
130
131 #[cfg(feature = "NSString")]
132 #[unsafe(method(preferredFilename))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn preferredFilename(&self) -> Option<Retained<NSString>>;
135
136 #[cfg(feature = "NSString")]
137 #[unsafe(method(setPreferredFilename:))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn setPreferredFilename(&self, preferred_filename: Option<&NSString>);
141
142 #[cfg(feature = "NSString")]
143 #[unsafe(method(filename))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn filename(&self) -> Option<Retained<NSString>>;
146
147 #[cfg(feature = "NSString")]
148 #[unsafe(method(setFilename:))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn setFilename(&self, filename: Option<&NSString>);
152
153 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
154 #[unsafe(method(fileAttributes))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn fileAttributes(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
157
158 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
159 #[unsafe(method(setFileAttributes:))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn setFileAttributes(&self, file_attributes: &NSDictionary<NSString, AnyObject>);
163
164 #[cfg(feature = "NSURL")]
165 #[unsafe(method(matchesContentsOfURL:))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn matchesContentsOfURL(&self, url: &NSURL) -> bool;
168
169 #[cfg(all(feature = "NSError", feature = "NSURL"))]
170 #[unsafe(method(readFromURL:options:error:_))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn readFromURL_options_error(
173 &self,
174 url: &NSURL,
175 options: NSFileWrapperReadingOptions,
176 ) -> Result<(), Retained<NSError>>;
177
178 #[cfg(all(feature = "NSError", feature = "NSURL"))]
179 #[unsafe(method(writeToURL:options:originalContentsURL:error:_))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn writeToURL_options_originalContentsURL_error(
182 &self,
183 url: &NSURL,
184 options: NSFileWrapperWritingOptions,
185 original_contents_url: Option<&NSURL>,
186 ) -> Result<(), Retained<NSError>>;
187
188 #[cfg(feature = "NSData")]
189 #[unsafe(method(serializedRepresentation))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn serializedRepresentation(&self) -> Option<Retained<NSData>>;
192
193 #[cfg(feature = "NSString")]
194 #[unsafe(method(addFileWrapper:))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn addFileWrapper(&self, child: &NSFileWrapper) -> Retained<NSString>;
197
198 #[cfg(all(feature = "NSData", feature = "NSString"))]
199 #[unsafe(method(addRegularFileWithContents:preferredFilename:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn addRegularFileWithContents_preferredFilename(
202 &self,
203 data: &NSData,
204 file_name: &NSString,
205 ) -> Retained<NSString>;
206
207 #[unsafe(method(removeFileWrapper:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn removeFileWrapper(&self, child: &NSFileWrapper);
210
211 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
212 #[unsafe(method(fileWrappers))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn fileWrappers(
215 &self,
216 ) -> Option<Retained<NSDictionary<NSString, NSFileWrapper>>>;
217
218 #[cfg(feature = "NSString")]
219 #[unsafe(method(keyForFileWrapper:))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn keyForFileWrapper(&self, child: &NSFileWrapper)
222 -> Option<Retained<NSString>>;
223
224 #[cfg(feature = "NSData")]
225 #[unsafe(method(regularFileContents))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn regularFileContents(&self) -> Option<Retained<NSData>>;
228
229 #[cfg(feature = "NSURL")]
230 #[unsafe(method(symbolicLinkDestinationURL))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn symbolicLinkDestinationURL(&self) -> Option<Retained<NSURL>>;
233 );
234}
235
236impl NSFileWrapper {
238 extern_methods!(
239 #[unsafe(method(init))]
240 #[unsafe(method_family = init)]
241 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
242
243 #[unsafe(method(new))]
244 #[unsafe(method_family = new)]
245 pub unsafe fn new() -> Retained<Self>;
246 );
247}
248
249impl NSFileWrapper {
251 extern_methods!(
252 #[cfg(feature = "NSString")]
253 #[deprecated = "Use -initWithURL:options:error: instead."]
254 #[unsafe(method(initWithPath:))]
255 #[unsafe(method_family = init)]
256 pub unsafe fn initWithPath(
257 this: Allocated<Self>,
258 path: &NSString,
259 ) -> Option<Retained<Self>>;
260
261 #[cfg(feature = "NSString")]
262 #[deprecated = "Use -initSymbolicLinkWithDestinationURL: and -setPreferredFileName:, if necessary, instead."]
263 #[unsafe(method(initSymbolicLinkWithDestination:))]
264 #[unsafe(method_family = init)]
265 pub unsafe fn initSymbolicLinkWithDestination(
266 this: Allocated<Self>,
267 path: &NSString,
268 ) -> Retained<Self>;
269
270 #[cfg(feature = "NSString")]
271 #[deprecated = "Use -matchesContentsOfURL: instead."]
272 #[unsafe(method(needsToBeUpdatedFromPath:))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn needsToBeUpdatedFromPath(&self, path: &NSString) -> bool;
275
276 #[cfg(feature = "NSString")]
277 #[deprecated = "Use -readFromURL:options:error: instead."]
278 #[unsafe(method(updateFromPath:))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn updateFromPath(&self, path: &NSString) -> bool;
281
282 #[cfg(feature = "NSString")]
283 #[deprecated = "Use -writeToURL:options:originalContentsURL:error: instead."]
284 #[unsafe(method(writeToFile:atomically:updateFilenames:))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn writeToFile_atomically_updateFilenames(
287 &self,
288 path: &NSString,
289 atomic_flag: bool,
290 update_filenames_flag: bool,
291 ) -> bool;
292
293 #[cfg(feature = "NSString")]
294 #[deprecated = "Instantiate a new NSFileWrapper with -initWithURL:options:error:, send it -setPreferredFileName: if necessary, then use -addFileWrapper: instead."]
295 #[unsafe(method(addFileWithPath:))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn addFileWithPath(&self, path: &NSString) -> Retained<NSString>;
298
299 #[cfg(feature = "NSString")]
300 #[deprecated = "Instantiate a new NSFileWrapper with -initWithSymbolicLinkDestinationURL:, send it -setPreferredFileName: if necessary, then use -addFileWrapper: instead."]
301 #[unsafe(method(addSymbolicLinkWithDestination:preferredFilename:))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn addSymbolicLinkWithDestination_preferredFilename(
304 &self,
305 path: &NSString,
306 filename: &NSString,
307 ) -> Retained<NSString>;
308
309 #[cfg(feature = "NSString")]
310 #[deprecated = "Use -symbolicLinkDestinationURL instead."]
311 #[unsafe(method(symbolicLinkDestination))]
312 #[unsafe(method_family = none)]
313 pub unsafe fn symbolicLinkDestination(&self) -> Retained<NSString>;
314 );
315}