ftp.nice.ch/pub/next/developer/resources/classes/MOKit.1.0.0.s.tar.gz#/MOKit_1.0.0/Documentation/Classes/MOPathString.rtf

This is MOPathString.rtf in view mode; [Download] [Up]

Version 1.0  Copyright ©1992, 1993, 1994 by Mike Ferris.  All Rights Reserved.
Mike Ferris  -  November 13th, 1993



MOPathString






Inherits From:	MOString : Object

Declared In:	MOKit/MOPathString.h





Class Description

MOPathString provides a bunch of methods for dealing with file paths (or any pathname-like strings).  It can hold the pathname of a file and return the directory component or the file component (the last path component is the "file" and the rest of the path is the "directory").  It can find the file's basename (the file name with one trailing suffix stripped off) or the file's extension.  It can pull path components out at random.  It can tell whether the path is absolute or relative.  It can see if the file exists and is accessible through the file system currently.  It can tell what type of file it is (assuming it exists).

The path component separator character and the separator used for file extensions are configurable.





Instance Variables

char 	pathSeparator;
char 	extSeparator;



pathSeparator 	The character used in the path to separate path components.

extSeparator	The character used in the path to separate file basenames and extensions.





Method Types

Initializing the class	+ initialize

Initializing instances	- initStringValueNoCopy:shouldFree:
- initPath:
- initDirectory:file:

Configuring instances	- setPath:
- setDirectory:file:
- setPathSeparator:
- pathSeparator
- setExtensionSeparator:
- extensionSeparator

Accessing parts of a path	- path
- directory
- file
- fileExtension
- fileBasename
- numberOfComponents
- componentAt:

Testing the file	- isRelative
- isAbsolute
- doesExistInFileSystem
- isDirectory
- isPlainFile
- isSymbolicLink
- isCharacterSpecial
- isBlockSpecial
- isSocket

Archiving	- write:
- read:

NXTransport	- encodeUsing:
- decodeUsing:






Class Methods

initialize
+ initialize

Sets the class version number.





Instance Methods

componentAt:
± componentAt:(int)index

Returns the path component at position index.  The components are number from 0 to numberOfComponents - 1.  The string object returned is of the same class as the object receiving this message.  Freeing the returned string is the caller's responsibility.  Returns nil if index is out of range.

See also:   ± path, ± directory, ± file, ± fileExtension, ± fileBasename, ± numberOfComponents




decodeUsing:
± decodeUsing:(id <NXDecoding>)portal

Decodes the instance after transmission by distributed object connection (specifically the separator characters).

See also:   ± decodeUsing:




directory
± directory

This returns everything to the left of the last occurrence of the path separator character in the path.  If the path separator character does not occur in the path, this returns an empty string.  The string returned is an instance of the same class as the receiver of this message.  Freeing the returned string is the caller's responsibility.

See also:   ± path, ± file, ± fileExtension, ± fileBasename, ± numberOfComponents, ± componentAt:




doesExistInFileSystem
± (BOOL)doesExistInFileSystem

This returns YES if our contents specifies a file that exists and is accessible to the current process.

See also:   ± isDirectory, ± isPlainFile, ± isSymbolicLink, ± isCharcterSpecial, ± isBlockSpecial, ± isSocket




encodeUsing:
± encodeUsing:(id <NXEncoding>)portal

Encodes the instance for transmission by distributed object connection (specifically the separator characters).

See also:   ± decodeUsing:




extensionSeparator
± (char)extensionSeparator

Returns the character used to separate file basenames and extensions.

See also:   ± setExtensionSeparator:




file
± file

This returns everything to the right of the last occurrence of the path separator character in the path.  If the path separator character does not occur in the path, this returns a copy of the whole string.  The string returned is an instance of the same class as the receiver of this message.  Freeing the returned string is the caller's responsibility.

See also:   ± path, ± directory, ± fileExtension, ± fileBasename, ± numberOfComponents, ± componentAt:




fileBasename
± fileBasename

This returns everything to the left of the last occurrence of the extension separator character in the substring that is normally returned by - file.  If the extension separator character does not occur in the path, this returns a copy of the whole string.  The string returned is an instance of the same class as the receiver of this message.  Freeing the returned string is the caller's responsibility.

See also:   ± path, ± directory, ± file, ± fileExtension, ± numberOfComponents, ± componentAt:




fileExtension
± fileExtension

This returns everything to the right of the last occurrence of the extension separator character in the substring that is normally returned by - file.  If the extension separator character does not occur in the path, this returns an empty string.  The string returned is an instance of the same class as the receiver of this message.  Freeing the returned string is the caller's responsibility.

See also:   ± path, ± directory, ± file, ± fileBasename, ± numberOfComponents, ± componentAt:




initDirectory:file:
± initDirectory:(const char *)dir file:(const char *)file

This is identical to calling - initFromFormat: with a format string of "%s%c%s".  The first string is dir the second is file.  The character in the middle is the default path separator '/'.

See also:  ± initStringValueNoCopy:shouldFree:, ± initPath:




initPath:
± initPath:(const char *)path

This is identical to calling - initStringValue:.

See also:   ± initStringValueNoCopy:shouldFree:, ± initDirectory:file:




initStringValueNoCopy: shouldFree:
± initStringValueNoCopy:(char *)s shouldFree:(BOOL)flag

This is the designated initializer for the class.  Besides the usual MOString implmentation, we use this opportunity to initialize the separator characters.  Path separator defaults to '/'.  File extension separator defaults to '.'.

See also:   ± initPath:, ± initDirectory:file:




isAbsolute
± (BOOL)isAbsolute

This returns YES if the path is not empty and DOES begin with the path separator character.

See also:   ± isRelative




isBlockSpecial
± (BOOL)isBlockSpecial

This returns YES if our contents specifies a file that exists and is accessible to the current process and that file is a block special file (like a device).

See also:   ± doesExistInFileSystem, ± isDirectory, ± isPlainFile, ± isSymbolicLink, ± isCharacterSpecial, ±€isSocket




isCharacterSpecial
± (BOOL)isCharacterSpecial

This returns YES if our contents specifies a file that exists and is accessible to the current process and that file is a character special file (like a device).

See also:   ± doesExistInFileSystem, ± isDirectory, ± isPlainFile, ± isSymbolicLink, ± isBlockSpecial, ±€isSocket




isDirectory
± (BOOL)isDirectory

This returns YES if our contents specifies a file that exists and is accessible to the current process and that file is a directory.

See also:   ± doesExistInFileSystem, ± isPlainFile, ± isSymbolicLink, ± isCharcterSpecial, ± isBlockSpecial, ±€isSocket




isPlainFile
± (BOOL)isPlainFile

This returns YES if our contents specifies a file that exists and is accessible to the current process and that file is a plain file.

See also:   ± doesExistInFileSystem, ± isDirectory, ± isSymbolicLink, ± isCharcterSpecial, ± isBlockSpecial, ±€isSocket




isRelative
± (BOOL)isRelative

This returns YES if the path is not empty and does NOT begin with the path separator character.

See also:   ± isAbsolute




isSocket
± (BOOL)isSocket

This returns YES if our contents specifies a file that exists and is accessible to the current process and that file is a socket.

See also:   ± doesExistInFileSystem, ± isDirectory, ± isPlainFile, ± isSymbolicLink, ± isCharacterSpecial, ±€isBlockSpecial




isSymbolicLink
± (BOOL)isSymbolicLink

This returns YES if our contents specifies a file that exists and is accessible to the current process and that file is a symbolic link.

See also:   ± doesExistInFileSystem, ± isDirectory, ± isPlainFile, ± isCharcterSpecial, ± isBlockSpecial, ±€isSocket




numberOfComponents
± (int)numberOfComponents

This returns the number of path components in the path.  That is the number of occurrences of the path separator character plus one.

See also:   ± path, ± directory, ± file, ± fileExtension, ± fileBasename, ± componentAt:




path
± (const char *)path

This is identical to - stringValue.

See also:   ± directory, ± file, ± fileExtension, ± fileBasename, ± numberOfComponents, ± componentAt:




pathSeparator
± (char)pathSeparator

Returns the character used to separate path components.

See also:   ± setPathSeparator:




read:
± read:(NXTypedStream *)stream

Reads the instance from the typed stream (specifically the separator characters).

See also:   ± write:




setDirectory:file:
± setDirectory:(const char *)dir file:(const char *)file

This is identical to calling - setFromFormat: with a format string of "%s%c%s".  The first string is dir the second is file.  The character in the middle is the path separator.

See also:  ± setPath:




setExtensionSeparator:
± setExtensionSeparator:(char)aChar

Use this to set the character used to separate file basenames and extensions.

See also:   ± extensionSeparator




setPath:
± setPath:(const char *)path

This is identical to calling - setStringValue:.

See also:   ± setDirectory:file:




setPathSeparator:
± setPathSeparator:(char)aChar

Use this to set the character used to separate path components.

See also:   ± pathSeparator




write:
± write:(NXTypedStream *)stream

Writes the instance to the typed stream (specifically the separator characters).

See also:   ± read:





These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.