ObjFW  Artifact [9ffc17fae1]

Artifact 9ffc17fae18f73305d2ce20dc731e8f76b86d2243474cdc1ac4f689358dbebe0:

  • File src/OFString+PathAdditions.h — part of check-in [7a488c3062] at 2018-03-11 00:37:56 on branch trunk — OFString: Move path handling into a category

    This is the first step to have different versions of those for different
    operating systems, rather than #ifdefs everywhere.

    This also has the nice side-effect of not having one implementation in
    OFString and another one in OFString_UTF8 anymore. The one in OFString
    was a generic version, while the one in OFString_UTF8 was one optimized
    for UTF-8 strings. Now only the version optimized for UTF-8 strings
    exists, as this is by far the most common string implementation used,
    and the overhead of converting from something else to UTF-8 is not more
    than converting to UTF-32. (user: js, size: 2237) [annotate] [blame] [check-ins using]


/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018
 *   Jonathan Schleifer <js@heap.zone>
 *
 * 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.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFString.h"

OF_ASSUME_NONNULL_BEGIN

#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_PathAdditions_reference;
#ifdef __cplusplus
}
#endif

@interface OFString (PathAdditions)
/*!
 * @brief The components of the string when interpreted as a path.
 */
@property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *pathComponents;

/*!
 * @brief The last path component of the string when interpreted as a path.
 */
@property (readonly, nonatomic) OFString *lastPathComponent;

/*!
 * @brief The file extension of string when interpreted as a path.
 */
@property (readonly, nonatomic) OFString *pathExtension;

/*!
 * @brief The directory name of the string when interpreted as a path.
 */
@property (readonly, nonatomic) OFString *stringByDeletingLastPathComponent;

/*!
 * @brief The string with the file extension of the path removed.
 */
@property (readonly, nonatomic) OFString *stringByDeletingPathExtension;

/*!
 * @brief The string interpreted as a path with relative sub paths resolved.
 */
@property (readonly, nonatomic) OFString *stringByStandardizingPath;

/*!
 * @brief Creates a path from the specified path components.
 *
 * @param components An array of components for the path
 * @return A new autoreleased OFString
 */
+ (OFString *)pathWithComponents: (OFArray OF_GENERIC(OFString *) *)components;

/*!
 * @brief Creates a new string by appending a path component.
 *
 * @param component The path component to append
 * @return A new, autoreleased OFString with the path component appended
 */
- (OFString *)stringByAppendingPathComponent: (OFString *)component;
@end

OF_ASSUME_NONNULL_END