From 83f1097598a63b64d2fec04f92f6f9c9e511b5af Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 21 Feb 2009 08:33:06 +0000 Subject: Added support for importing pieces from the command line. git-svn-id: http://svn.leocad.org/tags/leocad-0.75@738 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/library.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'common/library.cpp') diff --git a/common/library.cpp b/common/library.cpp index 0df8c51..9b49d62 100755 --- a/common/library.cpp +++ b/common/library.cpp @@ -1205,7 +1205,11 @@ bool PiecesLibrary::ImportTexture (const char* Name) p = strrchr(file1, '/'); if (!p) p = file1; +#ifdef LC_WINDOWS strupr(p); +#else + strlwr(p); +#endif p++; memset(NewTexName, 0, 9); @@ -1361,10 +1365,16 @@ bool PiecesLibrary::ImportLDrawPiece (const char* Filename) if (SaveLDrawPiece (&piece)) Sys_MessageBox ("Piece successfully imported."); else + { + fprintf(stderr, "Error saving library after importing %s.\n", Filename); Sys_MessageBox ("Error saving library."); + } } else + { + fprintf(stderr, "Error reading file %s\n", Filename); Sys_MessageBox ("Error reading file."); + } FreeLDrawPiece(&piece); @@ -1844,7 +1854,14 @@ static void decodefile(FILE *F, Matrix *mat, unsigned char defcolor, lineinfo_t* strcat (fn, "p/"); strcat (fn, filename); +#ifdef LC_WINDOWS strupr(filename); +#else + strlwr(filename); + for (unsigned int i = 0; i < strlen(filename); i++) + if (filename[i] == '\\') + filename[i] = '/'; +#endif for (val = 0; val < numvalid; val++) if (strcmp(filename, valid[val]) == 0) break; @@ -1882,6 +1899,8 @@ static void decodefile(FILE *F, Matrix *mat, unsigned char defcolor, lineinfo_t* info = info->next; fclose(tf); } + else + fprintf(stderr, "failed to load file %s (last attempt %s)\n", filename, fn); } break; case 2: @@ -1980,6 +1999,11 @@ static void decodeconnections(FILE *F, Matrix *mat, unsigned char defcolor, char strcat (fn, "P/"); strcat (fn, filename); +#ifdef LC_WINDOWS + strupr(filename); +#else + strlwr(filename); +#endif if (color == 16) color = defcolor; strupr(filename); -- cgit v1.2.3