Method for path name format conversion

Abstract: A method and apparatus for converting ASCII path names to parsed path name structures (22B, 32B) provides downward compatibility so that program modules written for modern operating systems which provide parsed path name structure inputs may be run under older operating systems which provide ASCII path name inputs. The method includes, in its most basic form, the steps of converting the prefix and file name of an ASCII path name to a unicode string (22A, 32A), then converting the unicode string to a parsed path structure (22B, 32B). In a preferred embodiment of the invention, the method is implemented in compiled object code written in the "C" computer programming language. The object code defines a parsed path structure, allocates buffers for stack variables, creates various pointers for scanning and counting functions, determines whether or not Uniform Naming Convention is used for the ASCII path name, converts the ASCII code to a unicode string, and then via scanning and counting, converts the first two character spaces in the unicode string to unicode numbers which indicate total string length and prefix length, respectively, and converts every other backslash character within the unicode string to a unicode number which identifies the length of the name component of the string which follows that particular number.

Description: FIELD OF THE INVENTION: This invention relates to a method for converting a string of formatted computer readable characters to a new string having a new format. DESCRIPTION OF RELATED ART: The move in the microcomputer industry from the Microsoft@ Windows™ version 3.X graphic environment, which runs under the 8/16-bit MS-DOS operating system, to the 32-bit Microsoft Windows 95 operating system has created a number of problems. Although Windows 95 has been designed so that it will run most software written for Windows ver. 3.X, programs which are written to take full advantage of the expanded capabilities of Windows 95 are often incompatible with Windows ver. 3.X. One of the incompatibilities between the old and new versions of Windows relates to path names. A path name is a unique identifier assigned to each file in a distributed data processing system. A path name, as it appears to the end user, has a similar format under both Windows ver. 3.X and Windows 95. The path name for any file always begins with a host identifier and ends with a file name. For example, "C:\WINDOWS\SYS\FILE.EXE" and "\\HOST\J\WINDOWS\SYS\FILE.EXE" are path names representative of those used with Windows ver 3.1. The first example does not follow the U niform N aming C onvention ( UNC ); the second example does. Directories, subdirectories and file names are limited to eight characters plus a three character extension. Generally, however, it is customary to use three character extensions for only file names. The UNC path name contains a host designator "host" and a shared designator "J". It will be noted that the UNC path name begins with double backslash characters, and that no colon character is used in the UNC name. Windows ver. 3.X uses A merican S tandard C ode for I nformation I nterchange ( ASCII for short). As each ASCII character is represented by a single byte (eight bits), 256 characters are the maximum that may be represented by the ASCII character set. Given the substantial decreases in the cost of both semiconductor and rotating magnetic storage memory, it is not surprising that ASCII code is being supplanted by a new, less-efficient but more capable code based on two-byte characters. The new code, called unicode, can distinguish between 65,536 characters, a quantity sufficient to encompass all foreign alphabets and the Chinese/Kanji characters. A path name under Windows ver. 3.X is stored as it appears on a computer screen. That is to say that, in the case of a UNC path name, it is stored as a string of ASCII characters which begins with the double backslash ("\\") and ends with the file name. The elements of the path name (e.g. host, shared, directory, subdirectories, and file name) are separated from one another by a single backslash ("\"). The string is terminated by a null byte (i.e. one which is set to 00HEX). A non-UNC path name is stored beginning with a letter for the drive designator and ends with the file name. A path name under Windows 95, on the other hand, is stored as a specially formatted unicode string known as parsed path name structure. Such a structure omits both the host name and the shared name in the case of a UNC name, or the drive designator in the case of a non-UNC path name, and has the following format: The first unicode value, or byte pair, specifies the total length of the parsed path name structure in bytes; the second unicode value indicates the length, in bytes, of the prefix (in this case, the prefix begins with the first unicode value of the string, and includes the directory and all subdirectories up to, but not including, the file name); the third byte pair indicates the length, in bytes, of the first path element in the prefix after the shared drive specifier or initial drive specifier (in the case of a non-UNC name), including the backslash character with which it begins; the third byte pair is followed by an array of unicode values corresponding to the characters in the name of the first path element; the first path element name array is followed by a subsequent byte pair which indicates the length, in bytes, of a second path element (if any); other subsequent byte length indicators and unicode arrays may follow, depending on the number of subdirectories which precede the file name; the final path element is the file name, and it, like other path element, is preceded by a byte length indicator. The need for the present invention arose during the development by Sun Microsystems, Inc. of a caching program module which would operate under both Windows 95 and Windows ver. 3.1 in a networked environment which may include modem connections. The module was initially written to operate with Windows 95. As such, it expected inputs, such as parsed path name structures, which are peculiar to Windows 95. If the program were to be run in a Windows ver. 3.X environment, the zero-terminated path names characteristic of Windows ver. 3.X would require conversion to the parsed path name structurcs. EP-A-0,588,488 describes a method for accessing the same computer file using different file name formats, of different operating systems. A directory specific request is received from a user. This directory specific request may contain no prefix or suffix, or this directory specific request may contain one of number of operating system specific prefixes/suffixes. Any prefix or suffix that is contained in the directory specific request is identified, for example DOS, MACINTOSH, OTHER. When no prefix/suffix is used in the request, the specified directory is searched, and it is determined if the requested item is found in the specified directory. When use of a prefix/suffix is found in the directory specific request, the found prefix/suffix is stripped, and a lookup strategy is used that is related to the found prefix/suffix. It is then determined if the requested item was found in the specified directory using the prefix/suffix related lookup strategy of one of the previous steps. Thus, four search strategies are provided; i.e., (1) when no prefix/suffix is used, (2) when the DOS prefix/suffix is used, (3) when the MACINTOSH prefix/suffix is used, and (4) when the OTHER prefix/suffix is used. IBM Technical Disclosure Bulletin, Vol.32, no. 10a, March 1990, pp. 456 - 462 "File Mapping in a heterogeneous distributed environment" discloses a method for converting path names between different formats. A method is described that handles the mapping of FILE IDs from one operating system to a second operating system. In order to accomplish this, a PROFILE must be created before mapping use. This PROFILE contains a set of RULES that determine how a given FILE ID is mapped from a first operating system to a second operating system pair, and the details of the RULES must differ depending upon the specific operating systems involved in the operating system pair since a logical connection is established between two different operating systems for each different RULE. M. Davis et al in "Unicode"; 1990 IEEE International Conference on Systems, Man and Cybernetics, Conference Proceedings, 4 - 7 November 1990, Los Angeles, CA, USA, pages 499 - 504, discusses the fundamental design principles for encoding characters in computers using Unicode. SUMMARY OF THE INVENTION The present invention provides a method for converting an ASCII path name to a parsed path name structure in accordance with the appended claims. In accordance with this invention, the above problem has been solved by the development of an efficient method implemented in conjunction with a computing system for converting a zero-terminated ASCII path name to a parsed path name structure. The above computer implemented steps in another implementation of the invention are provided as an article of manufacture, i.e., a computer storage medium containing a computer program of instructions for performing the above described steps. The great advantage and utility of the present invention is the efficient conversion of ASCII path names to parsed path name structures. The invention permits program modules designed to run under operating systems that provide parsed path name structure inputs to run under other operating systems which provide only ASCII path name inputs. The foregoing and other features, utilities and advantages of the invention will be apparent from the following more particular description of a preferred embodiment of the invention as illustrated in the accompanying object code listing and in the drawings. Brief Description of Drawings Fig. 1 illustrates a representational computing system and operating environment for performing the computer implemented steps of the method in accordance with the invention; and Fig. 2 is a flow chart depicting buffer contents at various stages during the conversion of a non-UNC ASCII path name to a parsed path name structure; and Fig. 3 is a flow chart depicting buffer contents at various stages during the conversion of a UNC ASCII path name to a parsed path name structure. Detailed Description of Preferred Embodiments The embodiments of the invention described herein may be implemented as logical operations in a distributed processing system having client and server computing systems. The logical operations of the present invention are implemented (1) as a sequence of computer implemented steps running on the computing system and (2) as interconnected machine modules within the computing system. The implementation is a matter of choice that is dependent on the performance requirements of the computing system implementing the invention. Accordingly, the logical operations making up the embodiments of the invention described herein are referred to variously as operations, steps or modules. The operating environment in which the present invention is used encompasses the general distributed computing system, wherein general purpose computers, workstations, or personal computers are connected via communication links of various types, in a client-server arrangement, wherein programs and data, many in the form of objects, are made available by various members of the system. Some of the elements of a general purpose workstation computer are shown in Figure 1, wherein a processor 1 is shown, the processor having an input/output (I/O) section, a central processing unit (CPU) 3 and a memory section 4. The I/O section 2 is connected to a keyboard 5, a display unit 6, a disk storage unit 9 and a CD-ROM drive unit 7. The CD-ROM unit 7 can read a CD-ROM medium 8 which typically contains programs 10 and data. The computer program products containing mechanisms to effectuate the apparatus and methods of the present invention may reside in the memory section 4, or on a disk storage unit 9, or on the CD-ROM 8 of such a system. Examples of such systems include SPARC® systems offered by Sun MicroSystems, Inc., personal computers offered by IBM Corporation and by other manufacturers of IBM-compatible personal computers, and systems running the UNIX® operating system. As a starting point for describing the invention, an object code listing of a computer program which implements the method is provided. The program, written in C code, is considered to be a preferred implementation of the method. Although other high-level languages might be used to implement the method, C is considered to be particularly well-suited, as large portions of Windows ver. 3.X and Windows 95 are believed to have been written in C. Although it is assumed that those having ordinary skill in the art of computer programming will fully understand the logic and function of the heretofore listed computer program, a general description of the program is provided to assist the reader. The program begins with several type definition statements and with the definition of a parsed path structure. The parsed path structure is defined as being comprised of multiple elements, each of which is an array of unicode characters. The "NameJam" program converts the ASCII pathname first to an unparsed unicode character string and later converts the unparsed string to a parsed path name structure. The NameJam program begins with the definition of various pointers and the allocation of various stack variables. The parsed path name structure will be assembled in a buffer designated pppath. The ASCII path name is loaded in a buffer designated PathName. Prior to converting the ASCII path name to the unparsed unicode character string, the NameJam program must first determine whether or not the ASCII path name follows the Uniform Naming Convention (UNC). An ASCII path name which does not follow the UNC begins with a drive specifier character followed, respectively, by a colon character, a single backslash character, a prefix character string, another single backslash character, and a file name character string. On the other hand, an ASCII path name which follows the UNC begins with a pair of adjacent backslash characters followed, respectively, by a host name character string, a single backslash character, a shared name character string (which may be only a single character), a single backslash character, a prefix character string (which may include several elements separated by backslash characters), another single backslash character, and a file name character string. It should be noted that each backslash character preceding a path element is considered to be a part of that path element. Examples of both a non-UNC ASCII path name and a UNC ASCII path name are, respectively: C:\WINDOWS\SYS\FILE.EXE (non-UNC) and \\DENVER\J\WINDOWS\SYS\FILE.EXE (UNC) If the ASCII path name follows the UNC, only the portion of the path name after the shared name and beginning with a backslash character is converted to a unicode character string and two dummy characters are placed at the beginning of the string. Alternatively, the conversion is begun two characters to the left of the fourth backslash character (i.e., at the backslash character immediately to the left of the character "J" in the UNC example above) and no dummy characters are placed at the beginning of the string. In either case, the result is the same. If the ASCII path name does not follow the UNC, it is assumed that the path name begins with a drive specifier, followed by a colon character and a backslash character, respectively. The entire non-UNC path name is converted to a unicode character string. A character by character conversion of the ASCII path name to unicode is effected, and the buffer designated pppath is sequentially filled with the unicode characters, thus creating an unparsed unicode character string. After all required character codes of the ASCII path name are converted to unicode values, and the unicode values have been written to the pppath buffer, a null unicode character is appended to the end of the unparsed string. A first pointer is set on the first unicode character of the unparsed string within buffer pppath. For the non-UNC example listed above, the first character is "C"; for the UNC example listed above, the first character is either the first extra character or the backslash ("\") character immediately preceding the character "J". The contents of buffer pppath are then scanned and counted in a direction from beginning to end, beginning with the first character in the unparsed string, and stopping on the appended null character. Let us call the total number of characters counted T+1, as this quantity includes the null character. The second pointer is then shifted one character toward the first character so that it points to the last character in the string that is immediately adjacent the appended null character. The count is adjusted during the shift so that the total number of characters in the unparsed string is determined to be the quantity T. T is doubled to reflect the fact that each unicode character value contains two bytes. Thus, for both the UNC and non-UNC examples above, 2T = 46 bytes. The first character position in the pppath buffer (i.e., the "C" for the non-UNC case and the first extra character, or the "\" immediately to the left of the character "J" for the UNC case) replaced with the unicode value for the number 46. A scanning operation is then performed with a third pointer, beginning with the unicode character pointed at by the second pointer (i.e., the character before the appended null), and in a direction toward the first pointer, stopping on the first backslash character encountered, and counting the number of characters, F, beginning with the character pointed at by the second pointer and ending with the first backslash character on which the third pointer stopped. For both the non-UNC and the UNC cases, the file name length F in unicode characters is equal 9. Thus the file name has a byte length of 2F, or 18 bytes. The backslash character to which the third pointer still points is replaced with the unicode value for the number 18. A number P is determined, which represents the length, in bytes, of the prefix. P is calculated by subtracting 2F from 2T, or F from T and doubling the result. For both the UNC and non-UNC cases shown above, P = 28 bytes. The second unicode character in the buffer (e.g., the colon for the non-UNC case and the second extra character or the character "J" for the UNC case are each replaced with the unicode value for the number 28. The scanning and counting process is repeated, each time moving in a direction toward the first pointer to the next backslash character, counting the number of characters in that string element, multiplying the number of characters by 2 to obtain the string element byte length, and replacing the backslash character immediately preceding each element with a unicode character which specifies the length of the element in bytes. For example, the backslash character immediately preceding the element "SYS" for both UNC and non-UNC strings is replaced with the unicode value for the number 8, which is the byte length of that element including the initial backslash, and the backslash character immediately preceding the element "WINDOWS" for both UNC and non-UNC strings is replaced with the unicode value for the number 16. At this stage of the process, the unparsed unicode string in buffer pppath has been completely converted to a parsed path name structure. The flow chart of Figure 2 depicts the contents of the PathName buffer and the pppath buffer at various stages during the conversion of a non-UNC ASCII path name to a parsed path name structure. The non-UNC ASCII path name is first loaded into the PathName buffer 21. Although the contents of PathName buffer 21 are depicted by characters, each byte-wide memory location within the PathName buffer 21 actually contains the binary ASCII code which represents the character. For example, the character "C" would be represented by the binary code "01100111" which is expressed in hexadecimal notation as "67". Still referring to Figure 2, for a non-UNC name, the entire path name is converted character-by-character to two-byte-wide unicode and sequentially loaded into the pppath buffer 22A as an un-parsed unicode character string. A null character, represented by sixteen zeros or "00 00" in hexidecimal code, is appended to the unparsed unicode character string. Still referring to Figure 2, the unparsed character string is then converted to a parsed path name structure, which is depicted by pppath buffer 22B (the same buffer as 22A, but with different contents) by converting the code for the first character (the letter "C") to a unicode numerical value which represents the length of the unicode character string, minus the null character, in bytes. Thus, the unicode value for "C" is replaced by the unicode value for 46 (the string length in bytes), which is represented by "00 2E" in hexidecimal notation. The unicode value for the colon character, "00 3A" is replaced by the unicode value for 28 (the length of the prefix in bytes), which is represented by "00 1C" in hexidecimal notation. The prefix, of course, comprises every character of the string from "C" to the third "S". The unicode value for each backslash character ("\") is replaced by the unicode value which corresponds to the length, in bytes, of the immediately following path element. That is to say, the first "00 2F" is replaced by "00 10", which represents the byte length of the unicode element "\WINDOWS"; the second "00 2F" is replaced by "00 08", which represents the byte length of the unicode element "\SYS"; and the third "00 2F" is replaced by "00 12", which represents the byte length of the unicode element "\FILE.EXE". Conversion of a UNC ASCII path name to a parsed path name structure proceeds by a slightly different process than that for non-UNC ASCII path names. The flow chart of Figure 3 depicts the contents of the PathName buffer and the pppath buffer at various stages during the conversion of a UNC ASCII path name to a parsed path name structure. The entire UNC ASCII path name is first loaded into the PathName buffer 31. It will be remembered that a UNC ASCII path name begins with two adjacent backslash characters. Thus, when the ASCII path name is scanned, the program identifies such a path name as a UNC path name. Those which begin with a single backslash are assumed to begin with a drive identifier, which is followed by a colon, the prefix and the file name. As in Figure 2, although the contents of PathName buffer 21 are depicted by characters, each byte-wide memory location within the PathName buffer 21 actually contains the binary ASCII code which represents the character. Still referring to Figure 3, for a UNC name, the portion of the path name to the left of the second character to the left of the prefix is discarded during the conversion of the ASCII path name character codes to unicode. The pppath buffer 32A contains the balance of the path name string, as converted to unicode. Conversion to the final parsed path name structure is effected in a manner identical to that employed for a non-UNC ASCII path name. The result is shown in pppath buffer 32B (the same buffer as buffer 32A, but with different contents). While the invention has been particularly shown and described with reference to a preferred embodiment thereof, it will be understood by those skilled in the art that various other changes in the form and details may be made therein without departing from the spirit and scope of the invention. For example, various techniques and sequences may be employed to count characters, determine element lengths, and substitute element length numbers for backslash characters, blank space characters and other characters at the beginning of the prefix.

Claims: A method for automatically converting an ASCII path name to a parsed path name structure (22B, 32B), said ASCII path name having a file name element and a prefix element, said prefix element having at least one subelement, said method comprising the computer implemented steps of: (a) defining a parsed path name structure; (b) allocating buffers for stack variables; (c) defining a set of scanning and counting functions and a set of arithmetic and character replacement functions and creating a plurality of pointers for use with said scanning and counting functions and said arithmetic and character replacement functions; (d) determining whether or not Uniform Naming Convention is used for the ASCII path name; (e) converting each character of the ASCII path name or a subset thereof to a corresponding unicode character, and sequentially writing each unicode character to a buffer to form an unparsed unicode string (22A, 32A); (f) employing the scanning and counting functions, in combination with the arithmetic and character replacement functions to convert a first pair of buffer locations to numerical values which are indicative of the total unicode string length and the prefix element length, respectively, and to replace each unicode character corresponding to a backslash character within said unicode string with a specific numerical value, indicative of a length, in bytes, associated with the path name element which began with the replaced backslash character. The method of Claim 1, in which the step of defining a parsed path name structure comprises defining a string of unicode characters, said string having a first unicode character which is assigned a first numerical value specifying a length, in bytes, of said string, said string further comprising a first array of unicode characters which represent said prefix element, said first array being followed by a second array of unicode characters which represent the file name element, said first unicode character being followed by a second unicode character which is assigned a second numerical value specifying a length, in bytes, of said prefix element plus four bytes which account for said first and second unicode characters, said second unicode character being followed by a third unicode character which is assigned a third numerical value specifying a length, in bytes of a first subelement of said prefix element, any further subelement of said prefix element and said file name element each being preceded by a corresponding unicode character which is assigned a numerical value specifying its length in bytes. The method of Claim 1, in which the step of determining whether or not the ASCII path name follows a Uniform Naming Convention (UNC) comprises identifying: an ASCII path name which does not follow said UNC beginning with a drive specifier character followed, respectively, by a colon character, a prefix beginning with a first single backslash character, and a file name beginning with a second single backslash character; an ASCII path name which follows said UNC beginning with a pair of adjacent backslash characters followed, respectively, by a host name, a shared name which begins with a first single backslash character, a prefix which begins with a second single backslash character, and a file name which begins with a third single backslash character. The method of Claim 3, wherein, for ASCII path names which do not follow said UNC, each character of the ASCII path name is converted to the corresponding unicode character and written to the buffer to form the unparsed unicode string (22A); and wherein, for ASCII path names which follow said UNC, two extra unicode characters are written at the beginning of the buffer, and each character of a subset of the ASCII pathname, said subset comprising the prefix element and the file name element, is converted to the corresponding unicode character and placed immediately adjacent said two extra characters, and wherein said two extra characters and the characters corresponding to said prefix element and said file name element comprise the unparsed unicode string (32A). The method of Claim 4, wherein conversion of the unparsed unicode string (22A, 32A) to a parsed path name structure (22B, 32B) comprises the steps of: (a) determining a number T, which represents a total number of unicode characters in said string beginning with a first character of said string and ending with a null unicode character which represents a last character of the unicode string; (b) assigning to said first unicode character of said unparsed unicode string a numerical value equivalent to 2T, which will specify the length of said parsed path name structure in bytes; (c) determining a number P, which represents a total number of unicode characters which comprise said prefix element; (d) assigning to the second unicode character of said unparsed unicode string a numerical value equivalent to 2P, which specifies the length of said prefix element in bytes. The method of Claim 5, which further comprises the step of determining the length of all subelements of which said prefix element is comprised and replacing a backslash character which begins each subelement within said prefix element with a numerical value specifying the length in bytes of that element. The method of Claim 3, wherein, for ASCII path names which do not follow said UNC, each character of the ASCII path name is converted to the corresponding unicode character and written to the buffer to form said unparsed unicode string (22A); and wherein, for ASCII path names which follow said UNC, each character of a subset of said ASCII pathname, said subset comprising only two characters preceding the prefix element, the prefix element, and the file name element, is converted to the corresponding unicode character and written to the buffer to form said unparsed unicode string (32A). The method of Claim 7, wherein conversion of the unparsed unicode string (22A, 32A) to a parsed path name structure (22B, 32B) comprises the steps of: (a) determining a number T, which represents a total number of unicode characters in said string beginning with a first character of said string and ending with a null unicode character which represents a last character of the unicode string; (b) assigning to said first unicode character of said unparsed unicode string a numerical value equivalent to 2T, which will specify the length of said parsed path name structure in bytes; (c) determining a number P, which represents a total number of unicode characters which comprise said prefix element; (d) assigning to the second unicode character of the unparsed unicode string a numerical value equivalent to 2P, which specifies the length of said prefix element in bytes. The method of Claim 8, wherein the total unicode string length T is determined by the steps of: (a) pointing to said first unicode character with a first pointer; (b) scanning said unparsed unicode string by advancing a second pointer in a direction from said first unicode character towards said null character, counting a total number, T+1, of unicode characters, including the null character; (c) moving said second pointer towards the first pointer by one unicode character, so that said second pointer points to said last unicode character, subtracting "1", to reflect this one character move, from T+1, and doubling the result to yield a value 2T indicative of the number of bytes required to represent T unicode characters. The method of Claim 8, wherein prefix element length 2P, in bytes is determined by the steps of: (a) scanning with a third pointer beginning at the unicode character pointed to by said second pointer and in a direction towards said first pointer, stopping said third pointer at a unicode character corresponding to a first backslash character encountered. and counting a number of characters, F, including said first backslash character: and (b) calculating the quantity, 2P, which represents the prefix element length in bytes, by subtracting F from T and doubling the result. A computer program product for automatically converting an ASCII path name to a parsed path name structure (22B, 32B), said ASCII path name having a file name element and a prefix element, said prefix element having at least one subelement, the computer program product comprising software code modules directly loadable into the internal memory of a digital computer for performing in the appropriate sequence all the steps of the method of any one of the preceding claims, when said product is used to control the operation of a computer.

Inventors: BERLINER BRIAN, HARPER JAMES M, BERLINER, BRIAN, HARPER, JAMES M.
Applicants: SUN MICROSYSTEMS INC, SUN MICROSYSTEMS, INC.
Application year: 1997
Main classification: G06F9
IPC codes: G06F13, G06F12, G06F17, G06F9