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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// The name of a file, expressed as a data buffer.
///
/// `FSFileName` is the class that carries filenames from the kernel to `FSModule` instances, and carries names back to the kernel as part of directory enumeration.
///
/// A filename is usually a valid UTF-8 sequence, but can be an arbitrary byte sequence that doesn't conform to that format.
/// As a result, the ``data`` property always contains a value, but the ``string`` property may be empty.
/// An `FSModule` can receive an `FSFileName` that isn't valid UTF-8 in two cases:
/// 1. A program passes erroneous data to a system call. The `FSModule` treats this situation as an error.
/// 2. An `FSModule` lacks the character encoding used for a file name.
/// This situation occurs because some file system formats consider a filename to be an arbitrary "bag of bytes," and leave character encoding up to the operating system.
/// Without encoding information, the `FSModule` can only pass back the names it finds on disk.
/// In this case, the behavior of upper layers such as
/// <doc
/// ://com.apple.documentation/documentation/Foundation/NSFileManager> is unspecified.
/// However, the `FSModule` must support looking up such names and using them as the source name of rename operations.
/// The `FSModule` must also be able to support filenames that are derivatives of filenames returned from directory enumeration.
/// Derivative filenames include Apple Double filenames (`"._Name"`), and editor backup filenames.
///
/// > Important: Don't subclass this class.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsfilename?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct FSFileName;
);
extern_conformance!(
unsafe impl NSCoding for FSFileName {}
);
extern_conformance!(
unsafe impl NSCopying for FSFileName {}
);
unsafe impl CopyingHelper for FSFileName {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for FSFileName {}
);
extern_conformance!(
unsafe impl NSSecureCoding for FSFileName {}
);
impl FSFileName {
extern_methods!(
/// The byte sequence of the filename, as a data object.
///
/// This property always provides a value.
#[unsafe(method(data))]
#[unsafe(method_family = none)]
pub unsafe fn data(&self) -> Retained<NSData>;
/// The filename, represented as a Unicode string.
///
/// If the value of the filename's ``FSFileName/data`` is not a valid UTF-8 byte sequence, this property is empty.
#[unsafe(method(string))]
#[unsafe(method_family = none)]
pub unsafe fn string(&self) -> Option<Retained<NSString>>;
/// The filename, represented as a potentially lossy conversion to a string.
///
/// The exact details of the string conversion may change in the future.
#[unsafe(method(debugDescription))]
#[unsafe(method_family = none)]
pub unsafe fn debugDescription(&self) -> Retained<NSString>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// Initializes a filename from a null-terminated character sequence.
///
/// > Note: This initializer is unavailable in Swift. Use ``initWithData:`` or ``initWithString:`` instead.
///
/// - Parameter name: A pointer to a C string.
///
/// # Safety
///
/// `name` must be a valid pointer.
#[unsafe(method(initWithCString:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCString(
this: Allocated<Self>,
name: NonNull<c_char>,
) -> Retained<Self>;
/// Initializes a file name by copying a character sequence from a byte array.
///
/// > Note: This initializer is unavailable in Swift. Use ``initWithData:`` or ``initWithString:`` instead.
///
/// - Parameters:
/// - bytes: A pointer to the character data to copy, up to a maximum of `length`. The sequence terminates if a `NUL` character exists prior to `length`.
/// - length: The size of the `bytes` array.
///
/// # Safety
///
/// `bytes` must be a valid pointer.
#[unsafe(method(initWithBytes:length:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithBytes_length(
this: Allocated<Self>,
bytes: NonNull<c_char>,
length: NSUInteger,
) -> Retained<Self>;
/// Creates a filename by copying a character sequence data object.
///
/// This initializer copies up to `name.length` characters of the sequence pointed to by `bytes`.
///
/// - Parameter name: The data object containing the character sequence to use for the filename. The sequence terminates if a `NUL` character exists prior to `name.length`.
#[unsafe(method(initWithData:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithData(this: Allocated<Self>, name: &NSData) -> Retained<Self>;
/// Creates a filename by copying a character sequence from a string instance.
///
/// This initializer copies the UTF-8 representation of the characters in `string`.
/// If `string` contains a `NUL` character, the sequence terminates.
///
/// - Parameter name: The string containing the character sequence to use for the filename.
#[unsafe(method(initWithString:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithString(this: Allocated<Self>, name: &NSString) -> Retained<Self>;
/// Creates a filename from a null-terminated character sequence.
///
/// - Parameter name: A pointer to a C string.
///
/// # Safety
///
/// `name` must be a valid pointer.
#[unsafe(method(nameWithCString:))]
#[unsafe(method_family = none)]
pub unsafe fn nameWithCString(name: NonNull<c_char>) -> Retained<Self>;
/// Creates a filename by copying a character sequence from a byte array.
///
/// - Parameters:
/// - bytes: A pointer to the character data to copy, up to a maximum of `length`. The sequence terminates if a `NUL` character exists prior to `length`.
/// - length: The size of the `bytes` array.
///
/// # Safety
///
/// `bytes` must be a valid pointer.
#[unsafe(method(nameWithBytes:length:))]
#[unsafe(method_family = none)]
pub unsafe fn nameWithBytes_length(
bytes: NonNull<c_char>,
length: NSUInteger,
) -> Retained<Self>;
/// Creates a filename by copying a character sequence data object.
///
/// This initializer copies up to `name.length` characters of the sequence pointed to by `bytes`.
///
/// - Parameter name: The data object containing the character sequence to use for the filename. The sequence terminates if a `NUL` character exists prior to `name.length`.
#[unsafe(method(nameWithData:))]
#[unsafe(method_family = none)]
pub unsafe fn nameWithData(name: &NSData) -> Retained<Self>;
/// Creates a filename by copying a character sequence from a string instance.
///
/// This initializer copies the UTF-8 representation of the characters in `string`.
/// If `string` contains a `NUL` character, the sequence terminates.
///
/// - Parameter name: The string containing the character sequence to use for the filename.
#[unsafe(method(nameWithString:))]
#[unsafe(method_family = none)]
pub unsafe fn nameWithString(name: &NSString) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
impl FSFileName {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}