ObjFW  Diff

Differences From Artifact [1976c624c2]:

To Artifact [ba984847f3]:


15
16
17
18
19
20
21
22
23
24



25
26
27
28
29
30
31
15
16
17
18
19
20
21



22
23
24
25
26
27
28
29
30
31







-
-
-
+
+
+








#include "config.h"

#include <errno.h>
#include <stdlib.h>
#include <string.h>

#import "OFEmbeddedURIHandler.h"
#import "OFMemoryStream.h"
#import "OFURI.h"
#import "OFEmbeddedIRIHandler.h"
#import "OFIRI.h"
#import "OFMemoryStream.h"

#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"

#ifdef OF_HAVE_THREADS
# import "OFOnce.h"
# import "OFPlainMutex.h"
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
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







-
-
+
+



-
-
-
+
+
+



-
+



-
+







	numEmbeddedFiles++;

#ifdef OF_HAVE_THREADS
	OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
#endif
}

@implementation OFEmbeddedURIHandler
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
@implementation OFEmbeddedIRIHandler
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	OFString *path;

	if (![URI.scheme isEqual: @"embedded"] || URI.host.length > 0 ||
	    URI.port != nil || URI.user != nil || URI.password != nil ||
	    URI.query != nil || URI.fragment != nil)
	if (![IRI.scheme isEqual: @"embedded"] || IRI.host.length > 0 ||
	    IRI.port != nil || IRI.user != nil || IRI.password != nil ||
	    IRI.query != nil || IRI.fragment != nil)
		@throw [OFInvalidArgumentException exception];

	if (![mode isEqual: @"r"])
		@throw [OFOpenItemFailedException exceptionWithURI: URI
		@throw [OFOpenItemFailedException exceptionWithIRI: IRI
							      mode: mode
							     errNo: EROFS];

	if ((path = URI.path) == nil) {
	if ((path = IRI.path) == nil) {
		@throw [OFInvalidArgumentException exception];
	}

#ifdef OF_HAVE_THREADS
	OFEnsure(OFPlainMutexLock(&mutex) == 0);
	@try {
#endif
106
107
108
109
110
111
112
113

114
115
116
117
106
107
108
109
110
111
112

113
114
115
116
117







-
+




		}
#ifdef OF_HAVE_THREADS
	} @finally {
		OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
	}
#endif

	@throw [OFOpenItemFailedException exceptionWithURI: URI
	@throw [OFOpenItemFailedException exceptionWithIRI: IRI
						      mode: mode
						     errNo: ENOENT];
}
@end