Overview
Comment: | Add +[lastComponentOfPath:] to OFFile. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2727e4282ff26bee451725923b2a5551 |
User & Date: | js on 2010-04-18 13:53:56 |
Other Links: | manifest | tags |
Context
2010-04-21
| ||
07:15 | Add +[copyFileAtPath:toPath:] and +[deleteDirectoryAtPath:] to OFFile. check-in: d92e0d0313 user: js tags: trunk | |
2010-04-18
| ||
13:53 | Add +[lastComponentOfPath:] to OFFile. check-in: 2727e4282f user: js tags: trunk | |
01:22 | Move objfw-config.in and objfw-compile into utils subdir. check-in: eba6fdcf3c user: js tags: trunk | |
Changes
Modified src/OFFile.h from [286a7957b4] to [17e8c1757d].
︙ | ︙ | |||
37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /** * \param fd A file descriptor, returned from for example open(). * It is not closed when the OFFile object is deallocated! * \return A new autoreleased OFFile */ + fileWithFileDescriptor: (int)fd; /** * \param path The path to check * \return A boolean whether there is a file at the specified path */ + (BOOL)fileExistsAtPath: (OFString*)path; /** | > > > > > > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /** * \param fd A file descriptor, returned from for example open(). * It is not closed when the OFFile object is deallocated! * \return A new autoreleased OFFile */ + fileWithFileDescriptor: (int)fd; /** * \param path The path for which the last component should be returned * \return The last component of the path */ + (OFString*)lastComponentOfPath: (OFString*)path; /** * \param path The path to check * \return A boolean whether there is a file at the specified path */ + (BOOL)fileExistsAtPath: (OFString*)path; /** |
︙ | ︙ |
Modified src/OFFile.m from [87ff6efbc7] to [b686c0a44c].
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #endif #ifndef S_IROTH # define S_IROTH 0 #endif #define DEFAULT_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH #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) { | > > > > > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #endif #ifndef S_IROTH # define S_IROTH 0 #endif #define DEFAULT_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH #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) { |
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | mode: mode] autorelease]; } + fileWithFileDescriptor: (int)fd_ { return [[[self alloc] initWithFileDescriptor: fd_] autorelease]; } + (BOOL)fileExistsAtPath: (OFString*)path { struct stat s; if (stat([path cString], &s) == -1) return NO; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 107 108 109 110 111 112 113 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 147 148 149 150 | mode: mode] autorelease]; } + fileWithFileDescriptor: (int)fd_ { return [[[self alloc] initWithFileDescriptor: fd_] autorelease]; } + (OFString*)lastComponentOfPath: (OFString*)path { 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 * removed, so return a new string anyway. */ if (i < 0) i++; return [OFString stringWithCString: path_c + i length: path_len - i]; } + (BOOL)fileExistsAtPath: (OFString*)path { struct stat s; if (stat([path cString], &s) == -1) return NO; |
︙ | ︙ |
Modified tests/Makefile from [5b09423e97] to [d78b55a6da].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFArrayTests.m \ OFDataArrayTests.m \ OFDictionaryTests.m \ OFHashesTests.m \ OFListTests.m \ OFNumberTests.m \ OFObjectTests.m \ ${OFPLUGINTESTS_M} \ OFStreamTests.m \ OFStringTests.m \ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFArrayTests.m \ OFDataArrayTests.m \ OFDictionaryTests.m \ OFFileTests.m \ OFHashesTests.m \ OFListTests.m \ OFNumberTests.m \ OFObjectTests.m \ ${OFPLUGINTESTS_M} \ OFStreamTests.m \ OFStringTests.m \ |
︙ | ︙ |
Added tests/OFFileTests.m version [d67d57f93a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 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 36 37 38 | /* * Copyright (c) 2008 - 2010 * Jonathan Schleifer <js@webkeks.org> * * 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 included in * the packaging of this file. */ #include "config.h" #import "OFFile.h" #import "OFAutoreleasePool.h" #import "OFString.h" #import "OFExceptions.h" #import "TestsAppDelegate.h" static OFString *module = @"OFFile"; @implementation TestsAppDelegate (OFFileTests) - (void)fileTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; TEST(@"+[lastComponentOfPath", [[OFFile lastComponentOfPath: @"/tmp"] isEqual: @"tmp"] && [[OFFile lastComponentOfPath: @"/tmp/"] isEqual: @"tmp"] && [[OFFile lastComponentOfPath: @"/"] isEqual: @""] && [[OFFile lastComponentOfPath: @"foo"] isEqual: @"foo"] /* && [[OFFile lastComponentOfPath: @"foo/bar"] isEqual: @"bar"] && [[OFFile lastComponentOfPath: @"foo/bar/baz/"] isEqual: @"baz"]*/) [pool drain]; } @end |
Modified tests/TestsAppDelegate.h from [f1bc853ff8] to [7e0781c6ed].
︙ | ︙ | |||
74 75 76 77 78 79 80 81 82 83 84 85 86 87 | @interface TestsAppDelegate (OFDataArrayTests) - (void)dataArrayTests; @end @interface TestsAppDelegate (OFDictionaryTests) - (void)dictionaryTests; @end @interface TestsAppDelegate (OFHashesTests) - (void)hashesTests; @end @interface TestsAppDelegate (OFListTests) - (void)listTests; | > > > > | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | @interface TestsAppDelegate (OFDataArrayTests) - (void)dataArrayTests; @end @interface TestsAppDelegate (OFDictionaryTests) - (void)dictionaryTests; @end @interface TestsAppDelegate (OFFileTests) - (void)fileTests; @end @interface TestsAppDelegate (OFHashesTests) - (void)hashesTests; @end @interface TestsAppDelegate (OFListTests) - (void)listTests; |
︙ | ︙ |
Modified tests/TestsAppDelegate.m from [11d0cb7f34] to [461a2d5844].
︙ | ︙ | |||
73 74 75 76 77 78 79 | withColor: 2]; [pool release]; } - (void)applicationDidFinishLaunching { [self objectTests]; | < > > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | withColor: 2]; [pool release]; } - (void)applicationDidFinishLaunching { [self objectTests]; [self stringTests]; [self fileTests]; [self hashesTests]; [self dataArrayTests]; [self arrayTests]; [self dictionaryTests]; [self listTests]; [self numberTests]; [self streamTests]; [self TCPSocketTests]; |
︙ | ︙ |