ObjFW  Check-in [61bbbc20ff]

Overview
Comment:Define functions unavailable on win32 and nop them there.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 61bbbc20ffc2f4a1423c605b47e98b9222e63f0c45ff6c311198f3a8fe4b0be0
User & Date: js on 2008-12-14 02:01:29
Other Links: manifest | tags
Context
2008-12-14
02:03
Fix check for asprintf. check-in: 094c6ad5f4 user: js tags: trunk
02:01
Define functions unavailable on win32 and nop them there. check-in: 61bbbc20ff user: js tags: trunk
01:45
Two new exceptions; fix 3 FIXMEs in OFTCPSocket. check-in: af9e349898 user: js tags: trunk
Changes

Modified src/OFFile.h from [3298445bd5] to [d94b85395e].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
 * the packaging of this file.
 */

#import <stdio.h>

#ifndef _WIN32
#import <sys/types.h>



#endif

#import "OFObject.h"
#import "OFStream.h"

/**
 * The OFFile class provides functions to read, write and manipulate files.







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 * the packaging of this file.
 */

#import <stdio.h>

#ifndef _WIN32
#import <sys/types.h>
#else
typedef int uid_t;
typedef int gid_t;
#endif

#import "OFObject.h"
#import "OFStream.h"

/**
 * The OFFile class provides functions to read, write and manipulate files.
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
 * Not available on Windows.
 *
 * \param path The path to the file of which the mode should be changed as a
 *	  C string
 * \param mode The new mode for the file
 * \return A boolean whether the operation succeeded
 */
#ifndef _WIN32
+ (BOOL)changeModeOfFile: (const char*)path
		  toMode: (mode_t)mode;
#endif

/**
 * Changes the owner of a file.
 *
 * Not available on Windows.
 *
 * \param path The path to the file of which the owner should be changed as a
 *	  C string
 * \param owner The new owner for the file
 * \param group The new group for the file
 * \return A boolean whether the operation succeeded
 */
#ifndef _WIN32
+ (BOOL)changeOwnerOfFile: (const char*)path
		  toOwner: (uid_t)owner
		 andGroup: (gid_t)group;
#endif

/**
 * Deletes a file.
 *
 * \param path The path to the file of which should be deleted as a C string
 * \return A boolean whether the operation succeeded
 */
+ (BOOL)delete: (const char*)path;

/**
 * Hardlinks a file.
 *
 * Not available on Windows.
 *
 * \param src The path to the file of which should be linked as a C string
 * \param dest The path to where the file should be linked as a C string
 * \return A boolean whether the operation succeeded
 */
#ifndef _WIN32
+ (BOOL)link: (const char*)src
	  to: (const char*)dest;
#endif

/**
 * Symlinks a file.
 *
 * Not available on Windows.
 *
 * \param src The path to the file of which should be symlinked as a C string
 * \param dest The path to where the file should be symlinked as a C string
 * \return A boolean whether the operation succeeded
 */
#ifndef _WIN32
+ (BOOL)symlink: (const char*)src
	     to: (const char*)dest;
#endif

/**
 * Initializes an already allocated OFFile.
 *
 * \param path The path to the file to open as a C string
 * \param mode The mode in which the file should be opened as a C string
 * \return An initialized OFFile







<
|

<












<
|


<







|










<
|

<










<
|

<







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
 * Not available on Windows.
 *
 * \param path The path to the file of which the mode should be changed as a
 *	  C string
 * \param mode The new mode for the file
 * \return A boolean whether the operation succeeded
 */

+ (void)changeModeOfFile: (const char*)path
		  toMode: (mode_t)mode;


/**
 * Changes the owner of a file.
 *
 * Not available on Windows.
 *
 * \param path The path to the file of which the owner should be changed as a
 *	  C string
 * \param owner The new owner for the file
 * \param group The new group for the file
 * \return A boolean whether the operation succeeded
 */

+ (void)changeOwnerOfFile: (const char*)path
		  toOwner: (uid_t)owner
		 andGroup: (gid_t)group;


/**
 * Deletes a file.
 *
 * \param path The path to the file of which should be deleted as a C string
 * \return A boolean whether the operation succeeded
 */
+ (void)delete: (const char*)path;

/**
 * Hardlinks a file.
 *
 * Not available on Windows.
 *
 * \param src The path to the file of which should be linked as a C string
 * \param dest The path to where the file should be linked as a C string
 * \return A boolean whether the operation succeeded
 */

+ (void)link: (const char*)src
	  to: (const char*)dest;


/**
 * Symlinks a file.
 *
 * Not available on Windows.
 *
 * \param src The path to the file of which should be symlinked as a C string
 * \param dest The path to where the file should be symlinked as a C string
 * \return A boolean whether the operation succeeded
 */

+ (void)symlink: (const char*)src
	     to: (const char*)dest;


/**
 * Initializes an already allocated OFFile.
 *
 * \param path The path to the file to open as a C string
 * \param mode The mode in which the file should be opened as a C string
 * \return An initialized OFFile

Modified src/OFFile.m from [8a9dff998b] to [ade2f827ca].

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
+ newWithPath: (const char*)path
      andMode: (const char*)mode
{
	return [[self alloc] initWithPath: path
				    andMode: mode];
}

#ifndef _WIN32
+ (BOOL)changeModeOfFile: (const char*)path
		  toMode: (mode_t)mode
{

	// FIXME: On error, throw exception



	return (chmod(path, mode) == 0 ? YES : NO);
}
#endif

#ifndef _WIN32
+ (BOOL)changeOwnerOfFile: (const char*)path
		  toOwner: (uid_t)owner
		 andGroup: (gid_t)group
{
	// FIXME: On error, throw exception

	return (chown(path, owner, group) == 0 ? YES : NO);
}
#endif


+ (BOOL)delete: (const char*)path
{
	// FIXME: On error, throw exception
	return (unlink(path) == 0 ? YES : NO);
}

#ifndef _WIN32
+ (BOOL)link: (const char*)src
	  to: (const char*)dest
{
	// FIXME: On error, throw exception

	return (link(src, dest) == 0 ? YES : NO);

}

+ (BOOL)symlink: (const char*)src
	     to: (const char*)dest
{
	// FIXME: On error, throw exception

	return (symlink(src, dest) == 0 ? YES : NO);
}
#endif


- initWithPath: (const char*)path
       andMode: (const char*)mode
{
	if ((self = [super init])) {
		if ((fp = fopen(path, mode)) == NULL)
			@throw [OFOpenFileFailedException newWithObject: self







<
|


>
|
>
>
>
|
<

|
|
|



|
>
|
<

|
>
|

|
|


<
|


|
>
|
>


|


|
>
|
<

>







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
+ newWithPath: (const char*)path
      andMode: (const char*)mode
{
	return [[self alloc] initWithPath: path
				    andMode: mode];
}


+ (void)changeModeOfFile: (const char*)path
		  toMode: (mode_t)mode
{
	/*
	 * FIXME: On error, throw exception
	 * FIXME: On Win32, change write access
	 */
#ifndef _WIN32
	chmod(path, mode);

#endif
}

+ (void)changeOwnerOfFile: (const char*)path
		  toOwner: (uid_t)owner
		 andGroup: (gid_t)group
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	chown(path, owner, group);

#endif
}

+ (void)delete: (const char*)path
{
	/* FIXME: On error, throw exception */
	unlink(path);
}


+ (void)link: (const char*)src
	  to: (const char*)dest
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	link(src, dest);
#endif
}

+ (void)symlink: (const char*)src
	     to: (const char*)dest
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	symlink(src, dest);

#endif
}

- initWithPath: (const char*)path
       andMode: (const char*)mode
{
	if ((self = [super init])) {
		if ((fp = fopen(path, mode)) == NULL)
			@throw [OFOpenFileFailedException newWithObject: self