Skip Menu |
 

This queue is for tickets about the PathTools CPAN distribution.

Report information
The Basics
Id: 75319
Status: new
Priority: 0/
Queue: PathTools

People
Owner: Nobody in particular
Requestors: shmuel+bitcard.org [...] patriot.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Cwd->
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1330271706-10809-140"
Content-Length: 0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 5168
Cwd->abs_path and File::Spec->rel2abs produce incorrect results in OS/2. [g:\bin]perl -v This is perl, v5.10.0 built for os2 Q:\programs\perl\lib\5.10.0\os2\Cwd.pm has $VERSION = '3.2501'; Q:\programs\perl\lib\5.10.0\File\Spec.pm has $VERSION = '3.2501'. Running under eComStation 2.0 GA (rebranded OS/2 4.52). Cwd->abs_path() is appending '/Cwd' to file names. File::Spec->rel2abs()is using the current drive instead of the drive specified in the call when the parameter specifies a drive but not a root directory; it is converting the double \ before a Universal Naming Convention (UNC) specification into a single / instead of a double /. To reproduce the problem, adjust the drive letters and directories in testrel2abs.cmd as needed and adjust the path in the perl invocation to point to wherever you have stored testrel2abs.pl. [g:\bin]testrel2abs F: CD \ecs G: CD \BIN Should output Cwd->abs_path(F:testpl.cmd) = F:/ecs/testpl.cmd Cwd->abs_path(G:testpl.cmd) = G:/bin/testpl.cmd Cwd->abs_path(testpl.cmd) = G:/bin/testpl.cmd Cwd->abs_path(\testpl.cmd) = G:/testpl.cmd Cwd->abs_path(\\server\testpl.cmd) = //server/bin/testpl.cmd File::Spec->rel2abs(F:testpl.cmd) = F:/ecs/testpl.cmd File::Spec->rel2abs(G:testpl.cmd) = G:/bin/testpl.cmd File::Spec->rel2abs(testpl.cmd) = G:/bin/testpl.cmd File::Spec->rel2abs(\testpl.cmd) = G:/testpl.cmd File::Spec->rel2abs(\\server\testpl.cmd) = //server/bin/testpl.cmd PERL h:\utility\testrel2abs.pl Cwd->abs_path(F:testpl.cmd) = F:/ecs/testpl.cmd/Cwd Cwd->abs_path(G:testpl.cmd) = G:/BIN/testpl.cmd/Cwd Cwd->abs_path(H:testpl.cmd) = H:/testpl.cmd/Cwd Cwd->abs_path(testpl.cmd) = G:/BIN/testpl.cmd/Cwd Cwd->abs_path(\testpl.cmd) = G:/testpl.cmd/Cwd Cwd->abs_path(\\server\testpl.cmd) = G:/server/testpl.cmd/Cwd File::Spec->rel2abs(F:testpl.cmd) = G:/BIN/testpl.cmd File::Spec->rel2abs(G:testpl.cmd) = G:/BIN/testpl.cmd File::Spec->rel2abs(H:testpl.cmd) = G:/BIN/testpl.cmd File::Spec->rel2abs(testpl.cmd) = G:/BIN/testpl.cmd File::Spec->rel2abs(\testpl.cmd) = /testpl.cmd File::Spec->rel2abs(\\server\testpl.cmd) = /server/testpl.cmd Note: while EMX has a _getcwd1 routine for returning the current directory of a specified drive, I recommend that you use the native API instead, as _getcwd1 does not check the buffer size. The relevant native OS/2 routines are documented as Show quoted text
--- Start of fair use quote from manual --- Gets the current default drive for the requesting process. #define INCL_DOSFILEMGR #include <os2.h> PULONG pdisknum; /* Address of the number of the default drive. */ PULONG plogical; /* Address of the bit map where the system returns the mapping of the logical drives. */ APIRET ulrc; /* Return Code. */ ulrc = DosQueryCurrentDisk(pdisknum, plogical); pdisknum (PULONG) - output Address of the number of the default drive. The value 1 means drive A, 2 means drive B, 3 means drive C, and so on. The maximum possible value is 26, which corresponds to drive Z. plogical (PULONG) - output Address of the bit map where the system returns the mapping of the logical drives. This bit map is stored in the low-order portion of the 32-bit area. Logical drives A to Z have one-to-one mapping with bit positions 0 to 25 of the map; for example, bit 0 represents drive A, bit 1 represents drive B, and so on. The settings of these bits indicate which drives exist, as follows: 0The logical drive does not exist. 1The logical drive exists. ulrc (APIRET) - returns Return Code. DosQueryCurrentDisk returns the following value: 0 NO_ERROR For a full list of error codes, see Errors. Gets the full path of the current directory for the requesting process on the specified drive. #define INCL_DOSFILEMGR #include <os2.h> ULONG disknum; /* The drive number. */ PBYTE pBuf; /* Address of the full path of the current directory. */ PULONG pcbBuf; /* Address of the length, in bytes, of the pBuf buffer. */ APIRET ulrc; /* Return Code. */ ulrc = DosQueryCurrentDir(disknum, pBuf, pcbBuf); disknum (ULONG) - input The drive number. The value 0 means the current drive, 1 means drive A, 2 means drive B, 3 means drive C, and so on. The maximum possible value is 26, which corresponds to drive Z. pBuf (PBYTE) - output Address of the full path of the current directory. pcbBuf (PULONG) - in/out Address of the length, in bytes, of the pBuf buffer. Input This field contains the length, in bytes, of the directory path buffer. Output If an error is returned because the buffer is too small, this field contains the required length, in bytes, of the buffer. ulrc (APIRET) - returns Return Code. DosQueryCurrentDir returns one of the following values: 0 NO_ERROR 15 ERROR_INVALID_DRIVE 26 ERROR_NOT_DOS_DISK 108 ERROR_DRIVE_LOCKED 111 ERROR_BUFFER_OVERFLOW For a full list of error codes, see Errors.
--------- end of quote --------
Subject: testrel2abs.pl
MIME-Version: 1.0
Content-Type: application/octet-stream; name="testrel2abs.pl"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="testrel2abs.pl"
Content-Transfer-Encoding: base64
Content-Length: 1128
Download testrel2abs.pl
text/x-perl 1.1k
#! perl use Cwd 'abs_path'; use File::Spec; print "\nCwd->abs_path(F:testpl.cmd) = ", Cwd->abs_path('F:testpl.cmd'); print "\nCwd->abs_path(G:testpl.cmd) = ", Cwd->abs_path('G:testpl.cmd'); print "\nCwd->abs_path(H:testpl.cmd) = ", Cwd->abs_path('H:testpl.cmd'); print "\nCwd->abs_path(testpl.cmd) = ", Cwd->abs_path('testpl.cmd'); print "\nCwd->abs_path(\\testpl.cmd) = ", Cwd->abs_path('\testpl.cmd'); print "\nCwd->abs_path(\\\\server\\testpl.cmd) = ", Cwd->abs_path('\\server\testpl.cmd'); print "\n"; print "\nFile::Spec->rel2abs(F:testpl.cmd) = ", File::Spec->rel2abs('F:testpl.cmd'); print "\nFile::Spec->rel2abs(G:testpl.cmd) = ", File::Spec->rel2abs('G:testpl.cmd'); print "\nFile::Spec->rel2abs(H:testpl.cmd) = ", File::Spec->rel2abs('H:testpl.cmd'); print "\nFile::Spec->rel2abs(testpl.cmd) = ", File::Spec->rel2abs('testpl.cmd'); print "\nFile::Spec->rel2abs(\\testpl.cmd) = ", File::Spec->rel2abs('\testpl.cmd'); print "\nFile::Spec->rel2abs(\\\\server\\testpl.cmd) = ", File::Spec->rel2abs('\\server\testpl.cmd');
Subject: testrel2abs.cmd
MIME-Version: 1.0
Content-Type: application/octet-stream; name="testrel2abs.cmd"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="testrel2abs.cmd"
Content-Transfer-Encoding: base64
Content-Length: 1044
Download testrel2abs.cmd
application/octet-stream 1k

Message body not shown because it is not plain text.

MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-10812-1331072071-212.75319-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
From: shmuel+bitcard.org [...] patriot.net
X-RT-Original-Encoding: utf-8
Content-Length: 696
Download (untitled) / with headers
text/plain 696b
On Sun Feb 26 10:55:07 2012, shmuel wrote: Show quoted text
> Cwd->abs_path and File::Spec->rel2abs produce incorrect results in OS/2.
The logic for in File::Spec::Win32 is applicable to OS/2, although the API is different. Also, in OS/2 the expression `CMD /c CD $drive:` will return the current directory for drive $drive. I'm not sure whether it is best to copy code from File::Spec::Win32 into File::Spec::OS2, subclass it or to make explicit calls to the win32 versions of various routines. I'm also not sure whether performance will be adequate using the CD hack above or whether the XS code is really needed. I can attempt to put a fix together if someone can provide style guidance and help with the XS.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.