ObjFW  Check-in [d931239e25]

Overview
Comment:Add OF_PATH_DELIM to macros.h.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d931239e253c19f624556bcecb7d1d2b9c79e833f5baecbedceed1c308b96523
User & Date: js on 2010-04-22 09:05:36
Other Links: manifest | tags
Context
2010-04-23
12:34
Nicer API for OFNumber. check-in: 03be48c518 user: js tags: trunk
2010-04-22
09:05
Add OF_PATH_DELIM to macros.h. check-in: d931239e25 user: js tags: trunk
2010-04-21
07:15
Add +[copyFileAtPath:toPath:] and +[deleteDirectoryAtPath:] to OFFile. check-in: d92e0d0313 user: js tags: trunk
Changes

Modified src/OFFile.m from [9c28a1ea8f] to [8e533c3fc6].

21
22
23
24
25
26
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
#include <dirent.h>

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


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

#ifndef O_BINARY
# define O_BINARY 0
#endif

#ifndef S_IRGRP
# define S_IRGRP 0
#endif
#ifndef S_IROTH
# define S_IROTH 0
#endif

#define DEFAULT_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
#define DIR_MODE DEFAULT_MODE | S_IXUSR | S_IXGRP | S_IXOTH

#ifndef _WIN32
# define PATH_DELIM '/'
#else
# define PATH_DELIM '\\'
#endif

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

static int parse_mode(const char *mode)
{
	if (!strcmp(mode, "r"))







>



















<
<
<
<
<
<







21
22
23
24
25
26
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
#include <dirent.h>

#import "OFFile.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

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

#ifndef O_BINARY
# define O_BINARY 0
#endif

#ifndef S_IRGRP
# define S_IRGRP 0
#endif
#ifndef S_IROTH
# define S_IROTH 0
#endif

#define DEFAULT_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
#define DIR_MODE DEFAULT_MODE | S_IXUSR | S_IXGRP | S_IXOTH







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

static int parse_mode(const char *mode)
{
	if (!strcmp(mode, "r"))
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
	const char *path_c = [path cString];
	size_t path_len = [path cStringLength];
	ssize_t i;

	if (path_len == 0)
		return @"";

	if (path_c[path_len - 1] == PATH_DELIM)
		path_len--;

	for (i = path_len - 1; i >= 0; i--) {
		if (path_c[i] == PATH_DELIM) {
			i++;
			break;
		}
	}

	/*
	 * Only one component, but the trailing delimiter might have been







|



|







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
	const char *path_c = [path cString];
	size_t path_len = [path cStringLength];
	ssize_t i;

	if (path_len == 0)
		return @"";

	if (path_c[path_len - 1] == OF_PATH_DELIM)
		path_len--;

	for (i = path_len - 1; i >= 0; i--) {
		if (path_c[i] == OF_PATH_DELIM) {
			i++;
			break;
		}
	}

	/*
	 * Only one component, but the trailing delimiter might have been

Modified src/OFString.m from [7f39ded0e7] to [1d5af0ad42].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

#import "asprintf.h"
#import "unicode.h"

#ifndef _WIN32
# define PATH_DELIM '/'
#else
# define PATH_DELIM '\\'
#endif

extern const uint16_t of_iso_8859_15[256];
extern const uint16_t of_windows_1252[256];

/* References for static linking */
void _references_to_categories_of_OFString()
{
	_OFHashing_reference = 1;







<
<
<
<
<
<







30
31
32
33
34
35
36






37
38
39
40
41
42
43
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

#import "asprintf.h"
#import "unicode.h"







extern const uint16_t of_iso_8859_15[256];
extern const uint16_t of_windows_1252[256];

/* References for static linking */
void _references_to_categories_of_OFString()
{
	_OFHashing_reference = 1;
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602

	len = [first cStringLength];
	memcpy(string, [first cString], len);
	i = len;

	while ((component = va_arg(args, OFString*)) != nil) {
		len = [component length];
		string[i] = PATH_DELIM;
		memcpy(string + i + 1, [component cString], len);
		i += len + 1;
	}

	string[i] = '\0';

	return self;







|







582
583
584
585
586
587
588
589
590
591
592
593
594
595
596

	len = [first cStringLength];
	memcpy(string, [first cString], len);
	i = len;

	while ((component = va_arg(args, OFString*)) != nil) {
		len = [component length];
		string[i] = OF_PATH_DELIM;
		memcpy(string + i + 1, [component cString], len);
		i += len + 1;
	}

	string[i] = '\0';

	return self;

Modified src/macros.h from [fc4c29980c] to [4ed7c72a5b].

42
43
44
45
46
47
48






49
50
51
52
53
54
55
#  define OF_X86_ASM
# elif defined(__ppc__) || defined(__PPC__)
#  define OF_PPC_ASM
# elif defined(__arm__) || defined(__ARM__)
#  define OF_ARM_ASM
# endif
#endif







static OF_INLINE uint16_t
OF_BSWAP16_CONST(uint16_t i)
{
	return (i & UINT16_C(0xFF00)) >> 8 |
	    (i & UINT16_C(0x00FF)) << 8;
}







>
>
>
>
>
>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#  define OF_X86_ASM
# elif defined(__ppc__) || defined(__PPC__)
#  define OF_PPC_ASM
# elif defined(__arm__) || defined(__ARM__)
#  define OF_ARM_ASM
# endif
#endif

#ifndef _WIN32
# define OF_PATH_DELIM '/'
#else
# define OF_PATH_DELIM '\\'
#endif

static OF_INLINE uint16_t
OF_BSWAP16_CONST(uint16_t i)
{
	return (i & UINT16_C(0xFF00)) >> 8 |
	    (i & UINT16_C(0x00FF)) << 8;
}