remove ExtractFilePath() ExtractFileBase() ExtractFileExtension()

This commit is contained in:
Garux 2021-10-04 11:34:15 +03:00
parent 82d038f6d1
commit 3960adf898
5 changed files with 14 additions and 41 deletions

View File

@ -256,7 +256,7 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream,
template<typename TextOutputStreamType>
TextOutputStreamType& ostream_write( TextOutputStreamType& t, const Vector4& v ){
return t << "[ " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << " ]";
return t << "[ " << v.x() << ' ' << v.y() << ' ' << v.z() << ' ' << v.w() << " ]";
}

View File

@ -1167,7 +1167,7 @@ inline void matrix4_pivoted_transform_by_euler_xyz_degrees( Matrix4& self, const
template<typename TextOutputStreamType>
inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const Matrix4& m ){
return ostream << m.x() << " " << m.y() << " " << m.z() << " " << m.t();
return ostream << m.x() << ' ' << m.y() << ' ' << m.z() << ' ' << m.t();
}
#endif

View File

@ -32,6 +32,8 @@
#include "inout.h"
#include "qstringops.h"
#include "qpathops.h"
#include "stream/stringstream.h"
#include "stream/textstream.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
@ -78,33 +80,25 @@ char *ex_argv[MAX_EX_ARGC];
#include "io.h"
void ExpandWildcards( int *argc, char ***argv ){
struct _finddata_t fileinfo;
int handle;
int i;
char filename[1024];
char filepath[1024];
char *path;
ex_argc = 0;
for ( i = 0 ; i < *argc ; i++ )
for ( int i = 0 ; i < *argc ; i++ )
{
path = ( *argv )[i];
char *path = ( *argv )[i];
if ( path[0] == '-'
|| ( !strchr( path, '*' ) && !strchr( path, '?' ) ) ) {
ex_argv[ex_argc++] = path;
continue;
}
handle = _findfirst( path, &fileinfo );
const int handle = _findfirst( path, &fileinfo );
if ( handle == -1 ) {
return;
}
ExtractFilePath( path, filepath );
do
{
sprintf( filename, "%s%s", filepath, fileinfo.name );
ex_argv[ex_argc++] = copystring( filename );
ex_argv[ex_argc++] = copystring( StringOutputStream( 256 )( PathFilenameless( path ), fileinfo.name ) );
} while ( _findnext( handle, &fileinfo ) != -1 );
_findclose( handle );

View File

@ -85,21 +85,3 @@ inline void FixDOSName( char *src ){
if ( *src == '\\' )
*src = '/';
}
// file directory with trailing slash
// NOTE: includes the slash, otherwise
// backing to an empty path will be wrong when appending a slash
inline void ExtractFilePath( const char *path, char *dest ){
strcpyQ( dest, path, path_get_filename_start( path ) - path + 1 ); // +1 for '\0'
}
// file name w/o extension
inline void ExtractFileBase( const char *path, char *dest ){
const char* start = path_get_filename_start( path );
const char* end = path_get_filename_base_end( start );
strcpyQ( dest, start, end - start + 1 ); // +1 for '\0'
}
inline void ExtractFileExtension( const char *path, char *dest ){
strcpy( dest, path_get_extension( path ) );
}

View File

@ -448,9 +448,6 @@ void MergeRelativePath( char *out, const char *absolute, const char *relative ){
int MiniMapBSPMain( Args& args ){
char minimapFilename[1024];
char basename[1024];
char path[1024];
char relativeMinimapFilename[1024];
bool autolevel;
float minimapSharpen;
float border;
@ -578,14 +575,14 @@ int MiniMapBSPMain( Args& args ){
MiniMapMakeMinsMaxs( mins, maxs, border, keepaspect );
if ( strEmpty( minimapFilename ) ) {
ExtractFileBase( source, basename );
ExtractFilePath( source, path );
sprintf( relativeMinimapFilename, g_game->miniMapNameFormat, basename );
MergeRelativePath( minimapFilename, path, relativeMinimapFilename );
const CopiedString basename( PathFilename( source ) );
const CopiedString path( PathFilenameless( source ) );
char relativeMinimapFilename[1024];
sprintf( relativeMinimapFilename, g_game->miniMapNameFormat, basename.c_str() );
MergeRelativePath( minimapFilename, path.c_str(), relativeMinimapFilename );
Sys_Printf( "Output file name automatically set to %s\n", minimapFilename );
}
ExtractFilePath( minimapFilename, path );
Q_mkdir( path );
Q_mkdir( CopiedString( PathFilenameless( minimapFilename ) ).c_str() );
if ( minimapSharpen >= 0 ) {
minimap.sharpen_centermult = 8 * minimapSharpen + 1;