1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* 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.
*
|
|
|
1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
*
* 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.
*
|
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
readdirMutex = [[OFMutex alloc] init];
atexit(releaseReaddirMutex);
#endif
#ifdef OF_WINDOWS
if ((module = LoadLibrary("msvcrt.dll")) != NULL)
_wutime64FuncPtr = (int (*)(const wchar_t *,
struct __utimbuf64 *))GetProcAddress(module, "_wutime64");
if ((module = LoadLibrary("kernel32.dll")) != NULL) {
createSymbolicLinkWFuncPtr =
(WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, DWORD))
GetProcAddress(module, "CreateSymbolicLinkW");
createHardLinkWFuncPtr =
(WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR,
LPSECURITY_ATTRIBUTES))
GetProcAddress(module, "CreateHardLinkW");
|
|
|
|
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
readdirMutex = [[OFMutex alloc] init];
atexit(releaseReaddirMutex);
#endif
#ifdef OF_WINDOWS
if ((module = GetModuleHandle("msvcrt.dll")) != NULL)
_wutime64FuncPtr = (int (*)(const wchar_t *,
struct __utimbuf64 *))GetProcAddress(module, "_wutime64");
if ((module = GetModuleHandleA("kernel32.dll")) != NULL) {
createSymbolicLinkWFuncPtr =
(WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, DWORD))
GetProcAddress(module, "CreateSymbolicLinkW");
createHardLinkWFuncPtr =
(WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR,
LPSECURITY_ATTRIBUTES))
GetProcAddress(module, "CreateHardLinkW");
|
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
|
return S_ISDIR(s.st_mode);
}
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [[OFFile alloc]
initWithPath: IRI.fileSystemRepresentation
mode: mode];
objc_autoreleasePoolPop(pool);
return [file autorelease];
}
- (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI
|
|
>
>
|
|
>
>
>
>
>
>
>
>
|
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
|
return S_ISDIR(s.st_mode);
}
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFFile *file;
@try {
file = [OFFile fileWithPath: IRI.fileSystemRepresentation
mode: mode];
} @catch (OFOpenItemFailedException *e) {
/* The thrown one has a path instead of an IRI set. */
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: mode
errNo: e.errNo];
}
[file retain];
objc_autoreleasePoolPop(pool);
return [file autorelease];
}
- (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI
|
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
|
const char *cPath = [path cStringWithEncoding: encoding];
const char *cName = [name cStringWithEncoding: encoding];
# if defined(OF_LINUX)
ssize_t size = lgetxattr(cPath, cName, NULL, 0);
# elif defined(OF_MACOS)
ssize_t size = getxattr(cPath, cName, NULL, 0, 0, XATTR_NOFOLLOW);
# endif
void *value = OFAllocMemory(1, size);
OFData *data;
@try {
# if defined(OF_LINUX)
if ((size = lgetxattr(cPath, cName, value, size)) < 0)
# elif defined(OF_MACOS)
if ((size = getxattr(cPath, cName, value, size, 0,
XATTR_NOFOLLOW)) < 0)
# endif
|
|
>
>
>
>
>
>
|
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
|
const char *cPath = [path cStringWithEncoding: encoding];
const char *cName = [name cStringWithEncoding: encoding];
# if defined(OF_LINUX)
ssize_t size = lgetxattr(cPath, cName, NULL, 0);
# elif defined(OF_MACOS)
ssize_t size = getxattr(cPath, cName, NULL, 0, 0, XATTR_NOFOLLOW);
# endif
void *value;
OFData *data;
if (size < 0)
@throw [OFGetItemAttributesFailedException
exceptionWithIRI: IRI
errNo: errno];
value = OFAllocMemory(1, size);
@try {
# if defined(OF_LINUX)
if ((size = lgetxattr(cPath, cName, value, size)) < 0)
# elif defined(OF_MACOS)
if ((size = getxattr(cPath, cName, value, size, 0,
XATTR_NOFOLLOW)) < 0)
# endif
|