︙ | | |
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
-
-
+
+
|
4B552555147AA5DB0003BF47 /* OFString_UTF8.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B552551147AA5DB0003BF47 /* OFString_UTF8.m */; };
4B55A0FF133ABEA900B58A93 /* OFThreadJoinFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A0F9133ABEA900B58A93 /* OFThreadJoinFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B55A100133ABEA900B58A93 /* OFThreadJoinFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A0FA133ABEA900B58A93 /* OFThreadJoinFailedException.m */; };
4B55A101133ABEA900B58A93 /* OFThreadStartFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A0FB133ABEA900B58A93 /* OFThreadStartFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B55A102133ABEA900B58A93 /* OFThreadStartFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A0FC133ABEA900B58A93 /* OFThreadStartFailedException.m */; };
4B55A103133ABEA900B58A93 /* OFThreadStillRunningException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A0FD133ABEA900B58A93 /* OFThreadStillRunningException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B55A104133ABEA900B58A93 /* OFThreadStillRunningException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A0FE133ABEA900B58A93 /* OFThreadStillRunningException.m */; };
4B55A10A133AC05100B58A93 /* OFOpenFileFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A107133AC05100B58A93 /* OFOpenFileFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B55A10B133AC05100B58A93 /* OFOpenFileFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A108133AC05100B58A93 /* OFOpenFileFailedException.m */; };
4B55A10A133AC05100B58A93 /* OFOpenItemFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A107133AC05100B58A93 /* OFOpenItemFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B55A10B133AC05100B58A93 /* OFOpenItemFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A108133AC05100B58A93 /* OFOpenItemFailedException.m */; };
4B55A112133AC24600B58A93 /* OFReadFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A10C133AC24500B58A93 /* OFReadFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B55A113133AC24600B58A93 /* OFReadFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A10D133AC24500B58A93 /* OFReadFailedException.m */; };
4B55A114133AC24600B58A93 /* OFReadOrWriteFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A10E133AC24500B58A93 /* OFReadOrWriteFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B55A115133AC24600B58A93 /* OFReadOrWriteFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A10F133AC24500B58A93 /* OFReadOrWriteFailedException.m */; };
4B55A116133AC24600B58A93 /* OFWriteFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A110133AC24500B58A93 /* OFWriteFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B55A117133AC24600B58A93 /* OFWriteFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A111133AC24600B58A93 /* OFWriteFailedException.m */; };
4B5B02BE18B288A400CE6AE4 /* OFINIFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B5B02BC18B288A400CE6AE4 /* OFINIFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
︙ | | |
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
|
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
|
-
-
+
+
|
4B552551147AA5DB0003BF47 /* OFString_UTF8.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFString_UTF8.m; path = src/OFString_UTF8.m; sourceTree = "<group>"; };
4B55A0F9133ABEA900B58A93 /* OFThreadJoinFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFThreadJoinFailedException.h; path = src/exceptions/OFThreadJoinFailedException.h; sourceTree = "<group>"; };
4B55A0FA133ABEA900B58A93 /* OFThreadJoinFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFThreadJoinFailedException.m; path = src/exceptions/OFThreadJoinFailedException.m; sourceTree = "<group>"; };
4B55A0FB133ABEA900B58A93 /* OFThreadStartFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFThreadStartFailedException.h; path = src/exceptions/OFThreadStartFailedException.h; sourceTree = "<group>"; };
4B55A0FC133ABEA900B58A93 /* OFThreadStartFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFThreadStartFailedException.m; path = src/exceptions/OFThreadStartFailedException.m; sourceTree = "<group>"; };
4B55A0FD133ABEA900B58A93 /* OFThreadStillRunningException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFThreadStillRunningException.h; path = src/exceptions/OFThreadStillRunningException.h; sourceTree = "<group>"; };
4B55A0FE133ABEA900B58A93 /* OFThreadStillRunningException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFThreadStillRunningException.m; path = src/exceptions/OFThreadStillRunningException.m; sourceTree = "<group>"; };
4B55A107133AC05100B58A93 /* OFOpenFileFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFOpenFileFailedException.h; path = src/exceptions/OFOpenFileFailedException.h; sourceTree = "<group>"; };
4B55A108133AC05100B58A93 /* OFOpenFileFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFOpenFileFailedException.m; path = src/exceptions/OFOpenFileFailedException.m; sourceTree = "<group>"; };
4B55A107133AC05100B58A93 /* OFOpenItemFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFOpenItemFailedException.h; path = src/exceptions/OFOpenItemFailedException.h; sourceTree = "<group>"; };
4B55A108133AC05100B58A93 /* OFOpenItemFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFOpenItemFailedException.m; path = src/exceptions/OFOpenItemFailedException.m; sourceTree = "<group>"; };
4B55A10C133AC24500B58A93 /* OFReadFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFReadFailedException.h; path = src/exceptions/OFReadFailedException.h; sourceTree = "<group>"; };
4B55A10D133AC24500B58A93 /* OFReadFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFReadFailedException.m; path = src/exceptions/OFReadFailedException.m; sourceTree = "<group>"; };
4B55A10E133AC24500B58A93 /* OFReadOrWriteFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFReadOrWriteFailedException.h; path = src/exceptions/OFReadOrWriteFailedException.h; sourceTree = "<group>"; };
4B55A10F133AC24500B58A93 /* OFReadOrWriteFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFReadOrWriteFailedException.m; path = src/exceptions/OFReadOrWriteFailedException.m; sourceTree = "<group>"; };
4B55A110133AC24500B58A93 /* OFWriteFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFWriteFailedException.h; path = src/exceptions/OFWriteFailedException.h; sourceTree = "<group>"; };
4B55A111133AC24600B58A93 /* OFWriteFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFWriteFailedException.m; path = src/exceptions/OFWriteFailedException.m; sourceTree = "<group>"; };
4B5B02BC18B288A400CE6AE4 /* OFINIFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFINIFile.h; path = src/OFINIFile.h; sourceTree = "<group>"; };
|
︙ | | |
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
|
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
|
-
-
+
+
|
4B17FF8E133A3034003E6DCD /* OFMemoryNotPartOfObjectException.m */,
4B7DD5831894358400990FD6 /* OFMoveItemFailedException.h */,
4B7DD5841894358400990FD6 /* OFMoveItemFailedException.m */,
4B90B789133AD46700BD33CB /* OFNotConnectedException.h */,
4B90B78A133AD46700BD33CB /* OFNotConnectedException.m */,
4B17FF75133A2B18003E6DCD /* OFNotImplementedException.h */,
4B17FF76133A2B18003E6DCD /* OFNotImplementedException.m */,
4B55A107133AC05100B58A93 /* OFOpenFileFailedException.h */,
4B55A108133AC05100B58A93 /* OFOpenFileFailedException.m */,
4B55A107133AC05100B58A93 /* OFOpenItemFailedException.h */,
4B55A108133AC05100B58A93 /* OFOpenItemFailedException.m */,
4B17FF81133A2DFB003E6DCD /* OFOutOfMemoryException.h */,
4B17FF82133A2DFB003E6DCD /* OFOutOfMemoryException.m */,
4B17FF79133A2C14003E6DCD /* OFOutOfRangeException.h */,
4B17FF7A133A2C15003E6DCD /* OFOutOfRangeException.m */,
4B55A10C133AC24500B58A93 /* OFReadFailedException.h */,
4B55A10D133AC24500B58A93 /* OFReadFailedException.m */,
4B55A10E133AC24500B58A93 /* OFReadOrWriteFailedException.h */,
|
︙ | | |
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
|
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
|
-
+
|
4B90B7A6133AD87D00BD33CB /* OFListenFailedException.h in Headers */,
4B6743F1163C384A00EB1E59 /* OFLockFailedException.h in Headers */,
4B17FFA1133A3335003E6DCD /* OFMalformedXMLException.h in Headers */,
4B17FF8F133A3036003E6DCD /* OFMemoryNotPartOfObjectException.h in Headers */,
4B7DD5851894358500990FD6 /* OFMoveItemFailedException.h in Headers */,
4B90B78F133AD46700BD33CB /* OFNotConnectedException.h in Headers */,
4B17FF77133A2B18003E6DCD /* OFNotImplementedException.h in Headers */,
4B55A10A133AC05100B58A93 /* OFOpenFileFailedException.h in Headers */,
4B55A10A133AC05100B58A93 /* OFOpenItemFailedException.h in Headers */,
4B17FF83133A2DFB003E6DCD /* OFOutOfMemoryException.h in Headers */,
4B17FF7B133A2C15003E6DCD /* OFOutOfRangeException.h in Headers */,
4B55A112133AC24600B58A93 /* OFReadFailedException.h in Headers */,
4B55A114133AC24600B58A93 /* OFReadOrWriteFailedException.h in Headers */,
4BFF3714177E17C100192782 /* OFRemoveItemFailedException.h in Headers */,
4B29BC41133AC4E80004B236 /* OFSeekFailedException.h in Headers */,
4B90B791133AD46700BD33CB /* OFSetOptionFailedException.h in Headers */,
|
︙ | | |
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
|
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
|
-
+
|
4B90B7A7133AD87D00BD33CB /* OFListenFailedException.m in Sources */,
4B6743F2163C384A00EB1E59 /* OFLockFailedException.m in Sources */,
4B17FFA2133A3335003E6DCD /* OFMalformedXMLException.m in Sources */,
4B17FF90133A3036003E6DCD /* OFMemoryNotPartOfObjectException.m in Sources */,
4B7DD5861894358500990FD6 /* OFMoveItemFailedException.m in Sources */,
4B90B790133AD46700BD33CB /* OFNotConnectedException.m in Sources */,
4B17FF78133A2B18003E6DCD /* OFNotImplementedException.m in Sources */,
4B55A10B133AC05100B58A93 /* OFOpenFileFailedException.m in Sources */,
4B55A10B133AC05100B58A93 /* OFOpenItemFailedException.m in Sources */,
4B17FF84133A2DFB003E6DCD /* OFOutOfMemoryException.m in Sources */,
4B17FF7C133A2C15003E6DCD /* OFOutOfRangeException.m in Sources */,
4B55A113133AC24600B58A93 /* OFReadFailedException.m in Sources */,
4B55A115133AC24600B58A93 /* OFReadOrWriteFailedException.m in Sources */,
4BFF3715177E17C100192782 /* OFRemoveItemFailedException.m in Sources */,
4B29BC42133AC4E80004B236 /* OFSeekFailedException.m in Sources */,
4B90B792133AD46700BD33CB /* OFSetOptionFailedException.m in Sources */,
|
︙ | | |
︙ | | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
-
+
|
#import "OFCreateDirectoryFailedException.h"
#import "OFCreateSymbolicLinkFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFLinkFailedException.h"
#import "OFLockFailedException.h"
#import "OFMoveItemFailedException.h"
#import "OFOpenFileFailedException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFRemoveItemFailedException.h"
#import "OFSeekFailedException.h"
#import "OFUnlockFailedException.h"
#import "OFWriteFailedException.h"
|
︙ | | |
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
|
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
-
+
-
|
#ifndef _WIN32
DIR *dir;
encoding = [OFSystemInfo native8BitEncoding];
if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL)
@throw [OFOpenFileFailedException exceptionWithPath: path
@throw [OFOpenItemFailedException exceptionWithPath: path
mode: @"r"
errNo: errno];
# if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS)
if (!of_mutex_lock(&mutex))
@throw [OFLockFailedException exception];
# endif
|
︙ | | |
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
-
+
-
|
if ((handle = FindFirstFileW([path UTF16String],
&fd)) == INVALID_HANDLE_VALUE) {
int errNo = 0;
if (GetLastError() == ERROR_FILE_NOT_FOUND)
errNo = ENOENT;
@throw [OFOpenFileFailedException exceptionWithPath: path
@throw [OFOpenItemFailedException exceptionWithPath: path
mode: @"r"
errNo: errNo];
}
@try {
do {
void *pool2 = objc_autoreleasePoolPush();
OFString *file;
|
︙ | | |
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
|
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
-
+
-
-
+
-
-
+
-
-
+
-
|
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_stat(path, &s) != 0)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithPath: path
@throw [OFOpenItemFailedException exceptionWithPath: path
mode: @"r"
errNo: errno];
return s.st_size;
}
+ (OFDate*)accessTimeOfItemAtPath: (OFString*)path
{
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_stat(path, &s) != 0)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithPath: path
@throw [OFOpenItemFailedException exceptionWithPath: path
mode: @"r"
errNo: errno];
/* FIXME: We could be more precise on some OSes */
return [OFDate dateWithTimeIntervalSince1970: s.st_atime];
}
+ (OFDate*)modificationTimeOfItemAtPath: (OFString*)path
{
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_stat(path, &s) != 0)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithPath: path
@throw [OFOpenItemFailedException exceptionWithPath: path
mode: @"r"
errNo: errno];
/* FIXME: We could be more precise on some OSes */
return [OFDate dateWithTimeIntervalSince1970: s.st_mtime];
}
+ (OFDate*)statusChangeTimeOfItemAtPath: (OFString*)path
{
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_stat(path, &s) != 0)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithPath: path
@throw [OFOpenItemFailedException exceptionWithPath: path
mode: @"r"
errNo: errno];
/* FIXME: We could be more precise on some OSes */
return [OFDate dateWithTimeIntervalSince1970: s.st_ctime];
}
#ifdef OF_HAVE_CHMOD
|
︙ | | |
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
|
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
|
+
-
+
-
|
@throw [OFInvalidArgumentException exception];
encoding = [OFSystemInfo native8BitEncoding];
length = readlink([path cStringWithEncoding: encoding],
destination, PATH_MAX);
if (length < 0)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithPath: path
@throw [OFOpenItemFailedException exceptionWithPath: path
mode: @"r"
errNo: errno];
return [OFString stringWithCString: destination
encoding: encoding
length: length];
}
#endif
|
︙ | | |
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
|
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
|
-
+
|
#elif defined(OF_HAVE_OFF64_T)
if ((_fd = open64([path cStringWithEncoding: [OFSystemInfo
native8BitEncoding]], flags, DEFAULT_MODE)) == -1)
#else
if ((_fd = open([path cStringWithEncoding: [OFSystemInfo
native8BitEncoding]], flags, DEFAULT_MODE)) == -1)
#endif
@throw [OFOpenFileFailedException
@throw [OFOpenItemFailedException
exceptionWithPath: path
mode: mode
errNo: errno];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
/*!
* @class OFOpenFileFailedException \
* OFOpenFileFailedException.h ObjFW/OFOpenFileFailedException.h
*
* @brief An exception indicating a file couldn't be opened.
*/
@interface OFOpenFileFailedException: OFException
{
OFString *_path, *_mode;
int _errNo;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy) OFString *path, *mode;
@property (readonly) int errNo;
#endif
/*!
* @brief Creates a new, autoreleased open file failed exception.
*
* @param path A string with the path of the file tried to open
* @param mode A string with the mode in which the file should have been opened
* @return A new, autoreleased open file failed exception
*/
+ (instancetype)exceptionWithPath: (OFString*)path
mode: (OFString*)mode;
/*!
* @brief Creates a new, autoreleased open file failed exception.
*
* @param path A string with the path of the file tried to open
* @param mode A string with the mode in which the file should have been opened
* @param errNo The errno of the error
* @return A new, autoreleased open file failed exception
*/
+ (instancetype)exceptionWithPath: (OFString*)path
mode: (OFString*)mode
errNo: (int)errNo;
/*!
* @brief Initializes an already allocated open file failed exception.
*
* @param path A string with the path of the file which couldn't be opened
* @param mode A string with the mode in which the file should have been opened
* @return An initialized open file failed exception
*/
- initWithPath: (OFString*)path
mode: (OFString*)mode;
/*!
* @brief Initializes an already allocated open file failed exception.
*
* @param path A string with the path of the file which couldn't be opened
* @param mode A string with the mode in which the file should have been opened
* @param errNo The errno of the error
* @return An initialized open file failed exception
*/
- initWithPath: (OFString*)path
mode: (OFString*)mode
errNo: (int)errNo;
/*!
* @brief Returns a string with the path of the file which couldn't be opened.
*
* @return A string with the path of the file which couldn't be opened
*/
- (OFString*)path;
/*!
* @brief Returns a string with the mode in which the file should have been
* opened.
*
* @return A string with the mode in which the file should have been opened
*/
- (OFString*)mode;
/*!
* @brief Returns the errno from when the exception was created.
*
* @return The errno from when the exception was created
*/
- (int)errNo;
@end
|
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFOpenFileFailedException.h"
#import "OFString.h"
@implementation OFOpenFileFailedException
+ (instancetype)exceptionWithPath: (OFString*)path
mode: (OFString*)mode
{
return [[[self alloc] initWithPath: path
mode: mode] autorelease];
}
+ (instancetype)exceptionWithPath: (OFString*)path
mode: (OFString*)mode
errNo: (int)errNo
{
return [[[self alloc] initWithPath: path
mode: mode
errNo: errNo] autorelease];
}
- init
{
OF_INVALID_INIT_METHOD
}
- initWithPath: (OFString*)path
mode: (OFString*)mode
{
self = [super init];
@try {
_path = [path copy];
_mode = [mode copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithPath: (OFString*)path
mode: (OFString*)mode
errNo: (int)errNo
{
self = [super init];
@try {
_path = [path copy];
_mode = [mode copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_path release];
[_mode release];
[super dealloc];
}
- (OFString*)description
{
if (_errNo != 0)
return [OFString stringWithFormat:
@"Failed to open file %@ with mode %@: %@",
_path, _mode, of_strerror(_errNo)];
else
return [OFString stringWithFormat:
@"Failed to open file %@ with mode %@!",
_path, _mode];
}
- (OFString*)path
{
OF_GETTER(_path, true)
}
- (OFString*)mode
{
OF_GETTER(_mode, true)
}
- (int)errNo
{
return _errNo;
}
@end
|