ObjFW  Diff

Differences From Artifact [cfa00f6d8b]:

To Artifact [95e5eb4c36]:


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

#include "config.h"

#include <stdio.h>
#include <string.h>
#include <unistd.h>

#ifndef _WIN32
#include <sys/types.h>
#include <sys/stat.h>
#endif

#import "OFFile.h"
#import "OFString.h"
#import "OFExceptions.h"

#ifdef _WIN32
#import <windows.h>
#endif

OFFile *of_stdin = nil;
OFFile *of_stdout = nil;
OFFile *of_stderr = nil;

@implementation OFFile







<


<






|







11
12
13
14
15
16
17

18
19

20
21
22
23
24
25
26
27
28
29
30
31
32
33

#include "config.h"

#include <stdio.h>
#include <string.h>
#include <unistd.h>


#include <sys/types.h>
#include <sys/stat.h>


#import "OFFile.h"
#import "OFString.h"
#import "OFExceptions.h"

#ifdef _WIN32
# import <windows.h>
#endif

OFFile *of_stdin = nil;
OFFile *of_stdout = nil;
OFFile *of_stderr = nil;

@implementation OFFile
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
	if (!SetFileAttributes([path cString], attrs))
		@throw [OFChangeFileModeFailedException newWithClass: self
								path: path
								mode: mode];
#endif
}


+ (void)changeOwnerOfFile: (OFString*)path
		  toOwner: (uid_t)owner
		    group: (gid_t)group
{
#ifndef _WIN32
	if (chown([path cString], owner, group))
		@throw [OFChangeFileOwnerFailedException newWithClass: self
								 path: path
								owner: owner
								group: group];
#else
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
#endif
}


+ (void)rename: (OFString*)from
	    to: (OFString*)to
{
#ifndef _WIN32
	if (rename([from cString], [to cString]))
#else







>




<





<
<
<
<

>







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
	if (!SetFileAttributes([path cString], attrs))
		@throw [OFChangeFileModeFailedException newWithClass: self
								path: path
								mode: mode];
#endif
}

#ifndef _WIN32
+ (void)changeOwnerOfFile: (OFString*)path
		  toOwner: (uid_t)owner
		    group: (gid_t)group
{

	if (chown([path cString], owner, group))
		@throw [OFChangeFileOwnerFailedException newWithClass: self
								 path: path
								owner: owner
								group: group];




}
#endif

+ (void)rename: (OFString*)from
	    to: (OFString*)to
{
#ifndef _WIN32
	if (rename([from cString], [to cString]))
#else
119
120
121
122
123
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
#else
	if (!DeleteFile([path cString]))
#endif
		@throw [OFDeleteFileFailedException newWithClass: self
							    path: path];
}


+ (void)link: (OFString*)src
	  to: (OFString*)dest
{
#ifndef _WIN32
	if (link([src cString], [dest cString]) != 0)
		@throw [OFLinkFailedException newWithClass: self
						    source: src
					       destination: dest];
#else
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
#endif
}

+ (void)symlink: (OFString*)src
	     to: (OFString*)dest
{
#ifndef _WIN32
	if (symlink([src cString], [dest cString]) != 0)
		@throw [OFSymlinkFailedException newWithClass: self
						       source: src
						  destination: dest];
#else
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
#endif
}


- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}








>



<




<
<
<
<





<




<
<
<
<

>







114
115
116
117
118
119
120
121
122
123
124

125
126
127
128




129
130
131
132
133

134
135
136
137




138
139
140
141
142
143
144
145
146
#else
	if (!DeleteFile([path cString]))
#endif
		@throw [OFDeleteFileFailedException newWithClass: self
							    path: path];
}

#ifndef _WIN32
+ (void)link: (OFString*)src
	  to: (OFString*)dest
{

	if (link([src cString], [dest cString]) != 0)
		@throw [OFLinkFailedException newWithClass: self
						    source: src
					       destination: dest];




}

+ (void)symlink: (OFString*)src
	     to: (OFString*)dest
{

	if (symlink([src cString], [dest cString]) != 0)
		@throw [OFSymlinkFailedException newWithClass: self
						       source: src
						  destination: dest];




}
#endif

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}