Using UNIX paths in Winelib

Using UNIX paths in Winelib

Winelib applications using the WineHQ version of Wine must use Windows format path names internally for file access. If you mix Windows APIs and standard libraries, this will effectively force you to use the Wine MSVCRT, and will limit your ability to use UNIX-specific file features. While the file dialogs will display a UNIX hierarchy, the file names returned are still in the Windows format.

There is a branch of Wine that includes UNIX path name entry points. This is implemented with git branches. Branches containing these changes are available at:

  • http://wine-git.troy.rollo.name/ - TroyRollo's git repository

    • the unix-path-apis branch contains only the changes required to support UNIX path name APIs. This does not include some related patches useful for Winelib applications. This is intended purely as a feature-specific branch for merging into other git branches.
    • the master branch is the development branch for TroyRollo, which contains the UNIX path name APIs, other changes useful for using Winelib for porting, and other unrelated changes. This branch is kept up-to-date with WineHQ regularly.

  • http://wine-git.corvu.com/ - the master branch contains the version of Wine used by CorVu for the Linux versions of some of their products.

This version makes use of a language that specifies the interface of affected API entry points in a way that allows for most of the UNIX path name entry points to be automatically generated. Where this is the case, the generated entry point performs all necessary conversions and forwards the call on to the standard entry points. The tool is found in tools/osfs, and the files containing the interface descriptions are in tools/osfs/data.

Not all entry points that may be required are implemented. If you plan on using these branches, it is your responsibility to check that the ones needed are implemented and to provide the interface definitions and (where necessary) implementation for the ones that are not already implemented.

The Unix path entry points have the same names as the Windows path entry points, but with "WineOSFS" prepended.

1. Building for UNIX paths

You will need to add to preprocessor defines to build your application for UNIX path names:

  • -DWINE_INCLUDE_OSFS_APIS - required to get the Unix path APIs included

  • -DWINE_USE_OSFS_APIS - required to make the Unix path APIs the ones used when no prefix or suffix is used in calls.

2. Implementing new entry points

2.1. Provide the interface definition

Add an interface definition in tools/osfs/data. If you create a new file, make sure that it is included by tools/osfs/data/master.tdl. You should find plenty of examples to use as a basis for the new entry point.

One area that may not be obvious is the $VARIANTS lines. These include the letter 'U', indicating that there is a UNIX path variant, and one of more of 'A' and 'W', indicating there is an 'A' and/or 'W' variant. Where the letter is uppercase, it indicates that that the corresponding entry point(s) should be automatically generated, otherwise only the declaration in the header files is automatically generated.

2.2. Make sure the header file includes the OSFS file

The interface definitions are used to create header files containing declarations for the UNIX entry points. You will need to make sure the standard header file conditionally includes the file containing the UNIX entry points. Look at the end of include/winbase.h to see how to do this.

2.3. If you have to manually implement an entry point

If you have to manually implement an entry point, make sure it appears in the corresponding spec file with a high ordinal.

2.4. Adjust dlls/*/Makefile.in

For automatically generated entry points in DLLs that do not already have automatically generated entry points, add a line:

OSFS_OBJS=osfs-autogen.o

Also add $(LIBPATHXLAT) to EXTRALIBS. You may also need to add $(LIBUNICODE) to EXTRALIBS.

Using UNIX paths in Winelib (last edited 2008-05-03 01:53:59 by nathan.n)