ObjFW  Diff

Differences From Artifact [cf4978d29a]:

To Artifact [0003c741c8]:


154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168







-
+







#ifdef OF_WINDOWS
static int (*_wutime64FuncPtr)(const wchar_t *, struct __utimbuf64 *);
static WINAPI BOOLEAN (*createSymbolicLinkWFuncPtr)(LPCWSTR, LPCWSTR, DWORD);
static WINAPI BOOLEAN (*createHardLinkWFuncPtr)(LPCWSTR, LPCWSTR,
    LPSECURITY_ATTRIBUTES);
#endif

#if defined(OF_FREEBSD) || defined(OF_NETBSD)
#ifdef OF_FREEBSD
static const char *namespaces[] = EXTATTR_NAMESPACE_NAMES;
static int numNamespaces = sizeof(namespaces) / sizeof(*namespaces);
#endif

#ifdef OF_WINDOWS
static OFTimeInterval
filetimeToTimeInterval(const FILETIME *filetime)
402
403
404
405
406
407
408

409
410
411
412
413
414
415
416




417
418
419
420
421
422
423
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428







+








+
+
+
+







		@throw [OFInvalidArgumentException exception];

	namespaceName = [*name substringToIndex: pos];
	cNamespace = [namespaceName cStringWithEncoding: [OFLocale encoding]];

	*name = [*name substringFromIndex: pos + 1];

# if defined(OF_FREEBSD)
	for (int i = 0; i < numNamespaces; i++) {
		if (strcmp(namespaces[i], cNamespace) == 0) {
			*namespace = i;
			return;
		}
	}

	@throw [OFInvalidArgumentException exception];
# elif defined(OF_NETBSD)
	if (extattr_string_to_namespace(cNamespace, namespace) == -1)
		@throw [OFInvalidArgumentException exception];
# endif
}
#endif

static void
setTypeAttribute(OFMutableFileAttributes attributes, Stat *s)
{
	if (S_ISREG(s->st_mode))
668
669
670
671
672
673
674

675







676
677
678
679

680
681
682
683
684

685
686
687
688
689

690
691
692








693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710

711
712
713
714
715
716
717
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691

692
693
694
695
696

697


698
699

700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728

729
730
731
732
733
734
735
736







+

+
+
+
+
+
+
+



-
+




-
+
-
-


-
+



+
+
+
+
+
+
+
+

















-
+







		}
	} @finally {
		OFFreeMemory(list);
	}
# elif defined(OF_FREEBSD) || defined(OF_NETBSD)
	names = [OFMutableArray array];

#  if defined(OF_FREEBSD)
	for (int i = 0; i < numNamespaces; i++) {
		int namespace = i;
		const char *cNamespace = namespaces[i];
#  elif defined(OF_NETBSD)
	for (size_t i = 0; extattr_namespaces[i] != 0; i++) {
		int namespace = extattr_namespaces[i];
		char *cNamespace;
#  endif
		ssize_t size;
		char *list;

		if ((size = extattr_list_link(cPath, i, NULL, 0)) < 0)
		if ((size = extattr_list_link(cPath, namespace, NULL, 0)) < 0)
			continue;

		list = OFAllocMemory(1, size);
		@try {
			OFString *namespace = [OFString
			OFString *namespaceName;
			    stringWithCString: namespaces[i]
				     encoding: encoding];
			char *iter;

			if ((size = extattr_list_link(cPath, i,
			if ((size = extattr_list_link(cPath, namespace,
			    list, size)) < 0)
				continue;

#  ifdef OF_NETBSD
			if (extattr_namespace_to_string(namespace,
			    &cNamespace) == -1)
				continue;
#  endif

			namespaceName = [OFString stringWithCString: cNamespace
							   encoding: encoding];
			iter = list;

			while (size > 0) {
				ssize_t length = *(unsigned char *)iter;
				OFString *name;

				iter++;
				size--;

				if (length > size)
					@throw [OFOutOfRangeException
					    exception];

				name = [OFString stringWithCString: iter
							  encoding: encoding
							    length: length];
				name = [OFString stringWithFormat:
				    @"%@.%@",  namespace, name];
				    @"%@.%@",  namespaceName, name];

				[names addObject: name];

				iter += length;
				size -= length;
			}
		} @finally {