Update of /cvsroot/opengtoolkit/lvzip/c_source
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19044
Modified Files:
lvutil.c
Log Message:
Hopefully successful bugfix for long path names in MacOS
Index: lvutil.c
===================================================================
RCS file: /cvsroot/opengtoolkit/lvzip/c_source/lvutil.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** lvutil.c 14 Dec 2007 21:36:20 -0000 1.5
--- lvutil.c 17 Dec 2007 13:41:22 -0000 1.6
***************
*** 84,90 ****
}
! static OSErr MakeFileSpec(int16 vol, int32 dirID, ConstStr255 path, FSSpec *fss)
{
! OSErr err = FSMakeFSSpec(vol, dirID, path, fss);
if (err)
{
--- 84,90 ----
}
! static OSErr MakeFileSpec(int16 vRefNum, int32 dirID, ConstStr255 path, FSSpec *fss)
{
! OSErr err = FSMakeFSSpec(vRefNum, dirID, path, fss);
if (err)
{
***************
*** 97,130 ****
else if (bdNamErr == err)
{
! /* MacOSX seems to return sometimes bdNamErr for longer absolute
! filenames, so we try to catch that too. */
! FSSpec fst;
Str255 temp;
! uChar *p;
! int32 i = 0;
!
DEBUGPRINTF(("MakeFileSpec: trying with subpaths"));
- /* remove the last elt of the path and see if we have success */
- PStrCpy(temp, path);
- p = (uChar*)&temp[PStrLen(path)];
! do
{
! for (; p > temp; p--, i++)
! if (*p == ':') break;
! if (p <= temp)
! return err;
! PStrLen(temp) = PStrLen(path) - (i + 1);
! err = FSMakeFSSpec(vol, dirID, temp, &fst);
if (err)
! DEBUGPRINTF(("FSMakeFSSpec: err2 = %ld, path = %p", err, temp));
! } while (bdNamErr == err);
! if (!err || (fnfErr == err))
{
! PStrLen(p) = i;
! err = MakeFileSpec(fst.vRefNum, fst.parID, p, fss);
! if (err)
! DEBUGPRINTF(("MakeFileSpec: err = %ld, path = %p", err, p));
}
}
--- 97,178 ----
else if (bdNamErr == err)
{
! /* MacOSX seems to return sometimes bdNamErr for longer filenames,
! so we try to catch that too. */
Str255 temp;
!
DEBUGPRINTF(("MakeFileSpec: trying with subpaths"));
! if (!vRefNum)
{
! HParamBlockRec hpb;
!
! hpb.volumeParam.ioVRefNum = vRefNum;
! if (path == NULL )
! {
! hpb.volumeParam.ioNamePtr = NULL;
! hpb.volumeParam.ioVolIndex = 0; /* use ioVRefNum only */
! }
! else
! {
! PStrCpy(temp, path);
! hpb.volumeParam.ioNamePtr = (StringPtr)temp;
! hpb.volumeParam.ioVolIndex = -1; /* use ioNamePtr/ioVRefNum combination */
! }
! err = OSErrToLVErr(PBHGetVInfoSync(&hpb));
if (err)
! DEBUGPRINTF(("PBHGetVInfo: err = %ld", err));
! else
! vRefNum = hpb.volumeParam.ioVRefNum;
! }
! if (vRefNum)
{
! FSSpec fst;
! uChar *p;
! int32 i = 0;
!
! /* remove the last elt(s) of the path and see if we have success */
! PStrCpy(temp, path);
! p = (uChar*)&temp[PStrLen(path)];
!
! do
! {
! for (; p > temp; p--, i++)
! {
! if (*p == ':')
! {
! break;
! p--, i++;
! }
! }
! if (p <= temp)
! return err;
! PStrLen(temp) = PStrLen(path) - i;
! err = FSMakeFSSpec(vRefNum, dirID, temp, &fst);
! if (err)
! DEBUGPRINTF(("FSMakeFSSpec: err2 = %ld, path = %p", err, temp));
! } while (bdNamErr == err);
!
! if (!err || (fnfErr == err))
! {
! CInfoPBRec cpb;
!
! PStrLen(p) = i;
!
! memset(&cpb, 0, sizeof(CInfoPBRec));
! cpb.hFileInfo.ioNamePtr = fst.name;
! cpb.hFileInfo.ioVRefNum = vRefNum;
! cpb.hFileInfo.ioDirID = fst.parID;
! cpb.dirInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
! err = OSErrToLVErr(PBGetCatInfoSync(&cpb));
! if (err)
! DEBUGPRINTF(("PBGetCatInfo: err = %ld", err));
! else
! {
! err = MakeFileSpec(vRefNum, cpb.dirInfo.ioDrDirID, p, fss);
! if (err)
! DEBUGPRINTF(("MakeFileSpec: err = %ld, path = %p", err, p));
! }
! }
}
}
|