Overview
Comment: | Add +[OFFile fileWithURL:mode:] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ec1ec2815dc47c3480849330ca555699 |
User & Date: | js on 2017-10-29 01:48:07 |
Other Links: | manifest | tags |
Context
2017-10-29
| ||
02:26 | Update buildsys check-in: 94175115c3 user: js tags: trunk | |
01:48 | Add +[OFFile fileWithURL:mode:] check-in: ec1ec2815d user: js tags: trunk | |
01:41 | OFFileManager: Add URL versions of all methods check-in: dd467ddb20 user: js tags: trunk | |
Changes
Modified src/OFFile.h from [a78b15002c] to [92705fc93e].
︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # undef BOOL # define OF_INVALID_FILE_HANDLE NULL typedef struct of_file_handle *of_file_handle_t; #endif OF_ASSUME_NONNULL_BEGIN /*! * @class OFFile OFFile.h ObjFW/OFFile.h * * @brief A class which provides methods to read and write files. */ @interface OFFile: OFSeekableStream { | > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # undef BOOL # define OF_INVALID_FILE_HANDLE NULL typedef struct of_file_handle *of_file_handle_t; #endif OF_ASSUME_NONNULL_BEGIN @class OFURL; /*! * @class OFFile OFFile.h ObjFW/OFFile.h * * @brief A class which provides methods to read and write files. */ @interface OFFile: OFSeekableStream { |
︙ | ︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 | * `a` | Write-only, create or append * `a+` | Read-write, create or append * @return A new autoreleased OFFile */ + (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode; /*! * @brief Creates a new OFFile with the specified native file handle. * * @param handle A native file handle. If OF_FILE_HANDLE_IS_FD is defined, this * is a file descriptor. The handle is closed when the OFFile * object is deallocated! * @return A new autoreleased OFFile | > > > > > > > > > > > > > > > > > > > > > | 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 | * `a` | Write-only, create or append * `a+` | Read-write, create or append * @return A new autoreleased OFFile */ + (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode; /*! * @brief Creates a new OFFile with the specified URL and mode. * * @param URL The URL to the file to open * @param mode The mode in which the file should be opened.@n * Possible modes are: * Mode | Description * ---------------|------------------------------------- * `r` | Read-only * `r+` | Read-write * `w` | Write-only, create or truncate * `wx` | Write-only, create or fail, exclusive * `w+` | Read-write, create or truncate * `w+x` | Read-write, create or fail, exclusive * `a` | Write-only, create or append * `a+` | Read-write, create or append * @return A new autoreleased OFFile */ + (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode; /*! * @brief Creates a new OFFile with the specified native file handle. * * @param handle A native file handle. If OF_FILE_HANDLE_IS_FD is defined, this * is a file descriptor. The handle is closed when the OFFile * object is deallocated! * @return A new autoreleased OFFile |
︙ | ︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | * `a+` | read-write, create, append * `ab+` or `a+b` | read-write, create, append, binary * @return An initialized OFFile */ - (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode; /*! * @brief Initializes an already allocated OFFile. * * @param handle A native file handle. If OF_FILE_HANDLE_IS_FD is defined, this * is a file descriptor. The handle is closed when the OFFile * object is deallocated! * @return An initialized OFFile */ - (instancetype)initWithHandle: (of_file_handle_t)handle OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | * `a+` | read-write, create, append * `ab+` or `a+b` | read-write, create, append, binary * @return An initialized OFFile */ - (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode; /*! * @brief Initializes an already allocated OFFile. * * @param URL The URL to the file to open * @param mode The mode in which the file should be opened.@n * Possible modes are: * Mode | Description * ---------------|------------------------------------- * `r` | read-only * `rb` | read-only, binary * `r+` | read-write * `rb+` or `r+b` | read-write, binary * `w` | write-only, create, truncate * `wb` | write-only, create, truncate, binary * `w` | read-write, create, truncate * `wb+` or `w+b` | read-write, create, truncate, binary * `a` | write-only, create, append * `ab` | write-only, create, append, binary * `a+` | read-write, create, append * `ab+` or `a+b` | read-write, create, append, binary * @return An initialized OFFile */ - (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode; /*! * @brief Initializes an already allocated OFFile. * * @param handle A native file handle. If OF_FILE_HANDLE_IS_FD is defined, this * is a file descriptor. The handle is closed when the OFFile * object is deallocated! * @return An initialized OFFile */ - (instancetype)initWithHandle: (of_file_handle_t)handle OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/OFFile.m from [3ace3f34b9] to [653ec63148].
︙ | ︙ | |||
25 26 27 28 29 30 31 32 | #include "unistd_wrapper.h" #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #import "OFFile.h" #import "OFString.h" | > | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include "unistd_wrapper.h" #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #import "OFFile.h" #import "OFLocalization.h" #import "OFString.h" #import "OFURL.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" |
︙ | ︙ | |||
178 179 180 181 182 183 184 185 186 187 188 189 190 191 | + (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode { return [[[self alloc] initWithPath: path mode: mode] autorelease]; } + (instancetype)fileWithHandle: (of_file_handle_t)handle { return [[[self alloc] initWithHandle: handle] autorelease]; } - (instancetype)init | > > > > > > > | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | + (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode { return [[[self alloc] initWithPath: path mode: mode] autorelease]; } + (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode { return [[[self alloc] initWithURL: URL mode: mode] autorelease]; } + (instancetype)fileWithHandle: (of_file_handle_t)handle { return [[[self alloc] initWithHandle: handle] autorelease]; } - (instancetype)init |
︙ | ︙ | |||
294 295 296 297 298 299 300 301 302 303 304 305 306 307 | @try { self = [self initWithHandle: handle]; } @catch (id e) { closeHandle(handle); @throw e; } return self; } - (instancetype)initWithHandle: (of_file_handle_t)handle { self = [super init]; | > > > > > > > > > > > > > > > > > > | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | @try { self = [self initWithHandle: handle]; } @catch (id e) { closeHandle(handle); @throw e; } return self; } - (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode { @try { void *pool = objc_autoreleasePoolPush(); self = [self initWithPath: [URL fileSystemRepresentation] mode: mode]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithHandle: (of_file_handle_t)handle { self = [super init]; |
︙ | ︙ |