Files
TeslaRel410/BORLAND/BC45/EXAMPLES/IDE/IDEHOOK/PATHSPEC.CPP
T
CydandClaude Fable 5 63312e07f9 source410: literal 4.10 source reconstruction + BC++ 4.52 fleet toolchain archived
- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
  is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
  Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
  (extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
  BT game source (never mixed into CODE/). Round 1-3 state:
  * 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
    (BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
    since 1996.
  * BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
    its binary-recorded line 400 exactly.
  * BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
    (Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
    TeamScore=12 flagged [T4]).
  * MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
    (VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
    the period compiler is the drift detector).
  * Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
    (per-TU verification sweep under authentic OPT.MAK flags).
  * README: corrected roadmap - MECH.HPP is the capstone grown with the mech
    TU reconstructions; BTREG.CPP green = the header-family milestone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 07:33:26 -05:00

281 lines
5.2 KiB
C++

//----------------------------------------------------------------------------
// IdeHook - (C) Copyright 1994 by Borland International
//----------------------------------------------------------------------------
#pragma hdrstop
#include <string.h>
#include <dos.h>
#include <commdlg.h>
#include "pathspec.h"
// //
// class PathSpec implementation //
// //
int
PathSpec::split()
{
return( _flags = ::fnsplit( _path, _drive, _dir, _file, _ext ) );
}
void
PathSpec::merge()
{
::fnmerge( _path, _drive, _dir, _file, _ext );
}
void
PathSpec::path(const char *path)
{
strcpy( _path, path );
split();
}
void
PathSpec::drive(const char *drive)
{
strcpy( _drive, drive );
merge();
}
void
PathSpec::dir(const char *dir)
{
strcpy( _dir, dir );
merge();
}
void
PathSpec::file(const char *file)
{
strcpy( _file, file );
merge();
}
void
PathSpec::ext(const char *ext)
{
strcpy( _ext, ext );
merge();
}
void
PathSpec::fileext( const char *fileExt )
{
char * p = (char *)(strchr(fileExt,'.'));
if( !p )
p = "";
ext( p );
*p = 0;
file( fileExt );
}
int
PathSpec::first()
{
if( ::findfirst( _path, &_dta, 0 ) == -1 )
return(0);
fileext( _dta.ff_name );
return( 1 );
}
int
PathSpec::next()
{
if( ::findnext( &_dta ) == -1 )
return( 0 );
fileext( _dta.ff_name );
return( 1 );
}
int
PathSpec::sameDrive( PathSpec & other )
{
if( *_drive == *other._drive )
return(1);
if( !*_drive )
{
_drive[0] = ::getdisk() + 'A' - 1;
_drive[1] = ':';
_drive[2] = 0;
}
else
{
if( !*other._drive )
{
other._drive[0] = ::getdisk() + 'A' - 1;
other._drive[1] = ':';
other._drive[2] = 0;
}
}
char s[3];
s[0] = *_drive;
s[1] = *other._drive;
s[2] = 0;
strlwr( s );
return( s[0] == s[1] );
}
int
PathSpec::isDirectory()
{
int lastCharPos = strlen( _path ) - 1;
char lastChar;
if(((lastChar = _path[lastCharPos]) == '\\') || (lastChar == '/'))
_path[lastCharPos] = 0;
int ret = (::findfirst( _path, &_dta, FA_DIREC ) != -1 ) &&
( _dta.ff_attrib & FA_DIREC );
_path[ lastCharPos ] = lastChar;
return( ret );
}
char *
PathSpec::stripTrailingSlash()
{
int lastCharPos = strlen( _path ) - 1;
if( (_path[lastCharPos] == '\\') || (_path[lastCharPos] == '/') )
_path[lastCharPos] = 0;
return( _path );
}
void
PathSpec::addTrailingSlash()
{
int lastCharPos = strlen( _path ) - 1;
if( (_path[lastCharPos] != '\\') && (_path[lastCharPos] != '/') )
{
strcat( _path, "\\" );
split();
}
}
int
PathSpec::newFileDialog
(
const char * filter,
const char * initialDir,
unsigned long hwndParent
)
{
return(
fileDialog
(
filter,
initialDir,
hwndParent,
OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST
)
);
}
int
PathSpec::openFileDialog
(
const char * filter,
const char * initialDir,
unsigned long hwndParent
)
{
return(
fileDialog
(
filter,
initialDir,
hwndParent,
OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST |
OFN_FILEMUSTEXIST
)
);
}
int
PathSpec::fileDialog
(
const char * filter,
const char * initialDir,
unsigned long hwndParent,
unsigned long flags
)
{
char szFile[256];
char *szFilter;
strcpy( szFile, file() );
if( *szFile )
strcat( szFile, ext() );
if( !filter )
filter = "All files (*.*)|(*.*)|";
szFilter = new char[ strlen(filter) + 1 ];
strcpy( szFilter, filter );
for ( unsigned short i = 0; szFilter[i] != 0; i++)
{
if (szFilter[i] == '|' )
szFilter[i] = 0;
}
/* Set all structure members to zero. */
OPENFILENAME ofn;
memset( &ofn, 0, sizeof(ofn) );
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = (HWND)(hwndParent);
ofn.lpstrFilter = szFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrInitialDir = initialDir;
ofn.Flags = flags;
int ret;
if ( (ret = GetOpenFileName(&ofn)) == 0 )
{
DWORD Errval = ::CommDlgExtendedError();
if (Errval != 0) // 0 value means user selected Cancel
{
char szErr[80];
wsprintf( szErr, "GetOpenFile error: %ld", Errval );
::MessageBox( ::GetActiveWindow(),szErr,"OpenFile",
MB_ICONEXCLAMATION | MB_OK );
}
}
else
{
path( ofn.lpstrFile );
}
delete szFilter;
return( ret );
}
// End of file