You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Aleksandr Vinokurov (JIRA)" <xe...@xml.apache.org> on 2008/06/05 15:11:45 UTC

[jira] Created: (XERCESC-1807) FileManagers: getFullPath Posix & Win32 implementations are not replaceable

FileManagers: getFullPath Posix & Win32 implementations are not replaceable 
----------------------------------------------------------------------------

                 Key: XERCESC-1807
                 URL: https://issues.apache.org/jira/browse/XERCESC-1807
             Project: Xerces-C++
          Issue Type: Bug
          Components: Utilities
    Affects Versions: Nightly build (please specify the date), 2.7.0
         Environment: Solaris 5.9 & 5.10, Windows XP 2002 SP2
            Reporter: Aleksandr Vinokurov


Simple examples with code copied from the WindowsFileMgr.cpp (rev. 556533) & PosixFileMgr.cpp (rev. 471747) from FileManagers directory (rev. 556533) confirm different operation of the code used to be an equal platform-dependant realization of one functionality.

Win32 example:
>-----------------<cut>-------------------<
int main(int argc, char ** argv) {
	if (argc == 1) {
		return 1;
	}

#define PATH_MAX 1024
	char buf[PATH_MAX + 1];
	char* namePart = 0;
	if (!::GetFullPathNameA((LPCSTR)argv[1], PATH_MAX, (LPSTR)&buf[0], (LPSTR*)&namePart)) {
		cerr << "GetFullPathNameA failed" << endl;
		return 2;
	}

	cout << buf << endl;

	return 0;
}
>-----------------<cut>-------------------<

Posix example:
>-----------------<cut>-------------------<
int main(int argc, char ** argv) {
        if (argc == 1) {
                return 1;
        }

        char buf[PATH_MAX + 1];
        char *retPath = realpath(argv[1], &buf[0]);

        if (!retPath) {
                cerr << "realpath failed with errno=" << errno << endl;
                return 2;
        }

        cout << retPath << endl;

        return 0;
}
>-----------------<cut>-------------------<

Run log on Windows:
>-----------------<cut>-------------------<
C:\TEMP>dir /s /b 
C:\TEMP\a.exe
C:\TEMP\log.txt
C:\TEMP\run.bat

C:\TEMP>a a 
C:\TEMP\a

C:\TEMP>a xxxxxxx 
C:\TEMP\xxxxxxx

C:\TEMP>a ../ 
C:\

>-----------------<cut>-------------------<

Run log on Solaris:
>-----------------<cut>-------------------<
ls -1
Makefile
a.out
./a.out a.out
/var/tmp/examples/a.out
./a.out xxxxxx
realpath failed with errno=2
gmake: [all] Error 2 (ignored)
./a.out ../
/var/tmp
>-----------------<cut>-------------------<

As you can see GetFullPathNameA does not fail on absent file while realpath does.

For now it is a really mess when using EntityResolver in XalanC XalanTransformer, as it calls getFullPath before calling the actual entityResolver method and catches up an exception if realpath can't find the file. My problem seems to be shared between Xerces-C++ and XalanC, but IMHO the differencies in getFullPath operations is prior.

run.bat:
>-----------------<cut>-------------------<
dir /s /b
a a
a xxxxxxx
a ../
>-----------------<cut>-------------------<

Makefile:
>-----------------<cut>-------------------<
all:
        ls -1
        -./a.out a.out
        -./a.out xxxxxx
        -./a.out ../
>-----------------<cut>-------------------<

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org