objc2_foundation/generated/
NSPathUtilities.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[cfg(feature = "NSString")]
11impl NSString {
12 extern_methods!(
13 #[cfg(feature = "NSArray")]
14 #[unsafe(method(pathWithComponents:))]
15 #[unsafe(method_family = none)]
16 pub unsafe fn pathWithComponents(components: &NSArray<NSString>) -> Retained<NSString>;
17
18 #[cfg(feature = "NSArray")]
19 #[unsafe(method(pathComponents))]
20 #[unsafe(method_family = none)]
21 pub unsafe fn pathComponents(&self) -> Retained<NSArray<NSString>>;
22
23 #[unsafe(method(isAbsolutePath))]
24 #[unsafe(method_family = none)]
25 pub unsafe fn isAbsolutePath(&self) -> bool;
26
27 #[unsafe(method(lastPathComponent))]
28 #[unsafe(method_family = none)]
29 pub unsafe fn lastPathComponent(&self) -> Retained<NSString>;
30
31 #[unsafe(method(stringByDeletingLastPathComponent))]
32 #[unsafe(method_family = none)]
33 pub unsafe fn stringByDeletingLastPathComponent(&self) -> Retained<NSString>;
34
35 #[unsafe(method(stringByAppendingPathComponent:))]
36 #[unsafe(method_family = none)]
37 pub fn stringByAppendingPathComponent(&self, str: &NSString) -> Retained<NSString>;
38
39 #[unsafe(method(pathExtension))]
40 #[unsafe(method_family = none)]
41 pub unsafe fn pathExtension(&self) -> Retained<NSString>;
42
43 #[unsafe(method(stringByDeletingPathExtension))]
44 #[unsafe(method_family = none)]
45 pub unsafe fn stringByDeletingPathExtension(&self) -> Retained<NSString>;
46
47 #[unsafe(method(stringByAppendingPathExtension:))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn stringByAppendingPathExtension(
50 &self,
51 str: &NSString,
52 ) -> Option<Retained<NSString>>;
53
54 #[unsafe(method(stringByAbbreviatingWithTildeInPath))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn stringByAbbreviatingWithTildeInPath(&self) -> Retained<NSString>;
57
58 #[unsafe(method(stringByExpandingTildeInPath))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn stringByExpandingTildeInPath(&self) -> Retained<NSString>;
61
62 #[unsafe(method(stringByStandardizingPath))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn stringByStandardizingPath(&self) -> Retained<NSString>;
65
66 #[unsafe(method(stringByResolvingSymlinksInPath))]
67 #[unsafe(method_family = none)]
68 pub unsafe fn stringByResolvingSymlinksInPath(&self) -> Retained<NSString>;
69
70 #[cfg(feature = "NSArray")]
71 #[unsafe(method(stringsByAppendingPaths:))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn stringsByAppendingPaths(
74 &self,
75 paths: &NSArray<NSString>,
76 ) -> Retained<NSArray<NSString>>;
77
78 #[cfg(feature = "NSArray")]
79 #[unsafe(method(completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:))]
80 #[unsafe(method_family = none)]
81 pub unsafe fn completePathIntoString_caseSensitive_matchesIntoArray_filterTypes(
82 &self,
83 output_name: Option<&mut Option<Retained<NSString>>>,
84 flag: bool,
85 output_array: Option<&mut Option<Retained<NSArray<NSString>>>>,
86 filter_types: Option<&NSArray<NSString>>,
87 ) -> NSUInteger;
88
89 #[unsafe(method(fileSystemRepresentation))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn fileSystemRepresentation(&self) -> NonNull<c_char>;
92
93 #[unsafe(method(getFileSystemRepresentation:maxLength:))]
94 #[unsafe(method_family = none)]
95 pub unsafe fn getFileSystemRepresentation_maxLength(
96 &self,
97 cname: NonNull<c_char>,
98 max: NSUInteger,
99 ) -> bool;
100 );
101}
102
103#[cfg(feature = "NSArray")]
105impl<ObjectType: Message> NSArray<ObjectType> {
106 extern_methods!(
107 #[cfg(feature = "NSString")]
108 #[unsafe(method(pathsMatchingExtensions:))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn pathsMatchingExtensions(
111 &self,
112 filter_types: &NSArray<NSString>,
113 ) -> Retained<NSArray<NSString>>;
114 );
115}
116
117#[cfg(feature = "NSString")]
118#[inline]
119pub unsafe extern "C-unwind" fn NSUserName() -> Retained<NSString> {
120 extern "C-unwind" {
121 fn NSUserName() -> *mut NSString;
122 }
123 let ret = unsafe { NSUserName() };
124 unsafe { Retained::retain_autoreleased(ret) }
125 .expect("function was marked as returning non-null, but actually returned NULL")
126}
127
128#[cfg(feature = "NSString")]
129#[inline]
130pub unsafe extern "C-unwind" fn NSFullUserName() -> Retained<NSString> {
131 extern "C-unwind" {
132 fn NSFullUserName() -> *mut NSString;
133 }
134 let ret = unsafe { NSFullUserName() };
135 unsafe { Retained::retain_autoreleased(ret) }
136 .expect("function was marked as returning non-null, but actually returned NULL")
137}
138
139#[cfg(feature = "NSString")]
140#[inline]
141pub unsafe extern "C-unwind" fn NSHomeDirectory() -> Retained<NSString> {
142 extern "C-unwind" {
143 fn NSHomeDirectory() -> *mut NSString;
144 }
145 let ret = unsafe { NSHomeDirectory() };
146 unsafe { Retained::retain_autoreleased(ret) }
147 .expect("function was marked as returning non-null, but actually returned NULL")
148}
149
150#[cfg(feature = "NSString")]
151#[inline]
152pub unsafe extern "C-unwind" fn NSHomeDirectoryForUser(
153 user_name: Option<&NSString>,
154) -> Option<Retained<NSString>> {
155 extern "C-unwind" {
156 fn NSHomeDirectoryForUser(user_name: Option<&NSString>) -> *mut NSString;
157 }
158 let ret = unsafe { NSHomeDirectoryForUser(user_name) };
159 unsafe { Retained::retain_autoreleased(ret) }
160}
161
162#[cfg(feature = "NSString")]
163#[inline]
164pub unsafe extern "C-unwind" fn NSTemporaryDirectory() -> Retained<NSString> {
165 extern "C-unwind" {
166 fn NSTemporaryDirectory() -> *mut NSString;
167 }
168 let ret = unsafe { NSTemporaryDirectory() };
169 unsafe { Retained::retain_autoreleased(ret) }
170 .expect("function was marked as returning non-null, but actually returned NULL")
171}
172
173#[cfg(feature = "NSString")]
174#[inline]
175pub unsafe extern "C-unwind" fn NSOpenStepRootDirectory() -> Retained<NSString> {
176 extern "C-unwind" {
177 fn NSOpenStepRootDirectory() -> *mut NSString;
178 }
179 let ret = unsafe { NSOpenStepRootDirectory() };
180 unsafe { Retained::retain_autoreleased(ret) }
181 .expect("function was marked as returning non-null, but actually returned NULL")
182}
183
184#[repr(transparent)]
187#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
188pub struct NSSearchPathDirectory(pub NSUInteger);
189impl NSSearchPathDirectory {
190 #[doc(alias = "NSApplicationDirectory")]
191 pub const ApplicationDirectory: Self = Self(1);
192 #[doc(alias = "NSDemoApplicationDirectory")]
193 pub const DemoApplicationDirectory: Self = Self(2);
194 #[doc(alias = "NSDeveloperApplicationDirectory")]
195 pub const DeveloperApplicationDirectory: Self = Self(3);
196 #[doc(alias = "NSAdminApplicationDirectory")]
197 pub const AdminApplicationDirectory: Self = Self(4);
198 #[doc(alias = "NSLibraryDirectory")]
199 pub const LibraryDirectory: Self = Self(5);
200 #[doc(alias = "NSDeveloperDirectory")]
201 pub const DeveloperDirectory: Self = Self(6);
202 #[doc(alias = "NSUserDirectory")]
203 pub const UserDirectory: Self = Self(7);
204 #[doc(alias = "NSDocumentationDirectory")]
205 pub const DocumentationDirectory: Self = Self(8);
206 #[doc(alias = "NSDocumentDirectory")]
207 pub const DocumentDirectory: Self = Self(9);
208 #[doc(alias = "NSCoreServiceDirectory")]
209 pub const CoreServiceDirectory: Self = Self(10);
210 #[doc(alias = "NSAutosavedInformationDirectory")]
211 pub const AutosavedInformationDirectory: Self = Self(11);
212 #[doc(alias = "NSDesktopDirectory")]
213 pub const DesktopDirectory: Self = Self(12);
214 #[doc(alias = "NSCachesDirectory")]
215 pub const CachesDirectory: Self = Self(13);
216 #[doc(alias = "NSApplicationSupportDirectory")]
217 pub const ApplicationSupportDirectory: Self = Self(14);
218 #[doc(alias = "NSDownloadsDirectory")]
219 pub const DownloadsDirectory: Self = Self(15);
220 #[doc(alias = "NSInputMethodsDirectory")]
221 pub const InputMethodsDirectory: Self = Self(16);
222 #[doc(alias = "NSMoviesDirectory")]
223 pub const MoviesDirectory: Self = Self(17);
224 #[doc(alias = "NSMusicDirectory")]
225 pub const MusicDirectory: Self = Self(18);
226 #[doc(alias = "NSPicturesDirectory")]
227 pub const PicturesDirectory: Self = Self(19);
228 #[doc(alias = "NSPrinterDescriptionDirectory")]
229 pub const PrinterDescriptionDirectory: Self = Self(20);
230 #[doc(alias = "NSSharedPublicDirectory")]
231 pub const SharedPublicDirectory: Self = Self(21);
232 #[doc(alias = "NSPreferencePanesDirectory")]
233 pub const PreferencePanesDirectory: Self = Self(22);
234 #[doc(alias = "NSApplicationScriptsDirectory")]
235 pub const ApplicationScriptsDirectory: Self = Self(23);
236 #[doc(alias = "NSItemReplacementDirectory")]
237 pub const ItemReplacementDirectory: Self = Self(99);
238 #[doc(alias = "NSAllApplicationsDirectory")]
239 pub const AllApplicationsDirectory: Self = Self(100);
240 #[doc(alias = "NSAllLibrariesDirectory")]
241 pub const AllLibrariesDirectory: Self = Self(101);
242 #[doc(alias = "NSTrashDirectory")]
243 pub const TrashDirectory: Self = Self(102);
244}
245
246unsafe impl Encode for NSSearchPathDirectory {
247 const ENCODING: Encoding = NSUInteger::ENCODING;
248}
249
250unsafe impl RefEncode for NSSearchPathDirectory {
251 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
252}
253
254#[repr(transparent)]
257#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
258pub struct NSSearchPathDomainMask(pub NSUInteger);
259bitflags::bitflags! {
260 impl NSSearchPathDomainMask: NSUInteger {
261 #[doc(alias = "NSUserDomainMask")]
262 const UserDomainMask = 1;
263 #[doc(alias = "NSLocalDomainMask")]
264 const LocalDomainMask = 2;
265 #[doc(alias = "NSNetworkDomainMask")]
266 const NetworkDomainMask = 4;
267 #[doc(alias = "NSSystemDomainMask")]
268 const SystemDomainMask = 8;
269 #[doc(alias = "NSAllDomainsMask")]
270 const AllDomainsMask = 0x0ffff;
271 }
272}
273
274unsafe impl Encode for NSSearchPathDomainMask {
275 const ENCODING: Encoding = NSUInteger::ENCODING;
276}
277
278unsafe impl RefEncode for NSSearchPathDomainMask {
279 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
280}
281
282#[cfg(all(feature = "NSArray", feature = "NSString"))]
283#[inline]
284pub unsafe extern "C-unwind" fn NSSearchPathForDirectoriesInDomains(
285 directory: NSSearchPathDirectory,
286 domain_mask: NSSearchPathDomainMask,
287 expand_tilde: bool,
288) -> Retained<NSArray<NSString>> {
289 extern "C-unwind" {
290 fn NSSearchPathForDirectoriesInDomains(
291 directory: NSSearchPathDirectory,
292 domain_mask: NSSearchPathDomainMask,
293 expand_tilde: Bool,
294 ) -> *mut NSArray<NSString>;
295 }
296 let ret = unsafe {
297 NSSearchPathForDirectoriesInDomains(directory, domain_mask, Bool::new(expand_tilde))
298 };
299 unsafe { Retained::retain_autoreleased(ret) }
300 .expect("function was marked as returning non-null, but actually returned NULL")
301}