ObjFW  Check-in [3f3746be03]

Overview
Comment:Add -[attributesOfItemAtIRI:] for embedded files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3f3746be03e899143baebca997107f30b1a958b16a11d8d32bb7602a8b894828
User & Date: js on 2024-09-08 17:02:15
Other Links: manifest | tags
Context
2024-09-14
22:08
ofhash: Accept --rmd160 as alias for --ripemd160 Leaf check-in: ae444256d2 user: js tags: trunk
2024-09-08
17:02
Add -[attributesOfItemAtIRI:] for embedded files check-in: 3f3746be03 user: js tags: trunk
2024-09-06
22:27
OFINIFile: Properly escape newlines check-in: 995f217b65 user: js tags: trunk
Changes

Modified src/OFEmbeddedIRIHandler.m from [275cbe280f] to [bb2d5eaecc].

22
23
24
25
26
27
28

29

30
31
32
33
34
35
36
#include <errno.h>
#include <stdlib.h>
#include <string.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"
#endif







>

>







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <errno.h>
#include <stdlib.h>
#include <string.h>

#import "OFEmbeddedIRIHandler.h"
#import "OFIRI.h"
#import "OFMemoryStream.h"
#import "OFNumber.h"

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

#ifdef OF_HAVE_THREADS
# import "OFOnce.h"
# import "OFPlainMutex.h"
#endif
122
123
124
125
126
127
128









































129
	}
#endif

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









































@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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
	}
#endif

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

- (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI
{
	OFString *path;

	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 ((path = IRI.path) == nil) {
		@throw [OFInvalidArgumentException exception];
	}

#ifdef OF_HAVE_THREADS
	OFEnsure(OFPlainMutexLock(&mutex) == 0);
	@try {
#endif
		for (size_t i = 0; i < numEmbeddedFiles; i++) {
			OFNumber *fileSize;

			if (![embeddedFiles[i].path isEqual: path])
				continue;

			fileSize = [OFNumber numberWithUnsignedLongLong:
			    embeddedFiles[i].size];

			return [OFDictionary dictionaryWithKeysAndObjects:
			    OFFileSize, fileSize,
			    OFFileType, OFFileTypeRegular,
			    nil];
		}
#ifdef OF_HAVE_THREADS
	} @finally {
		OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
	}
#endif

	@throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI
							      errNo: ENOENT];
}
@end