Subversion Repositories Games.Chess Giants

Rev

Rev 75 | Rev 83 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 75 Rev 81
Line 618... Line 618...
618
{
618
{
619
   // routine to get the size of a DDS/JPG/PNG/TGA/BMP image. JPEG code courtesy of wischik.com.
619
   // routine to get the size of a DDS/JPG/PNG/TGA/BMP image. JPEG code courtesy of wischik.com.
620
 
620
 
621
   wchar_t valid_pathname[MAX_PATH];
621
   wchar_t valid_pathname[MAX_PATH];
622
   unsigned char buffer[26];
622
   unsigned char buffer[26];
623
   struct _stat fileinfo;
-
 
624
   FILE *fp;
623
   FILE *fp;
625
   int length;
624
   int length;
626
   int pos;
625
   int pos;
627
 
626
 
628
   length = wcslen (imagefile_pathname); // get pathname length
627
   length = wcslen (imagefile_pathname); // get pathname length
Line 633... Line 632...
633
      // test if a corresponding .dds, .jpg, .jpeg, .png, .tga or .bmp file exists
632
      // test if a corresponding .dds, .jpg, .jpeg, .png, .tga or .bmp file exists
634
      wcsncpy_s (valid_pathname, WCHAR_SIZEOF (valid_pathname), imagefile_pathname, length - 1);
633
      wcsncpy_s (valid_pathname, WCHAR_SIZEOF (valid_pathname), imagefile_pathname, length - 1);
635
 
634
 
636
      // try these extensions one after the other...
635
      // try these extensions one after the other...
637
      wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"dds");
636
      wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"dds");
638
      if (_wstat (valid_pathname, &fileinfo) != 0)
637
      if (_waccess (valid_pathname, 0) != 0)
639
      {
638
      {
640
         wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"jpg");
639
         wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"jpg");
641
         if (_wstat (valid_pathname, &fileinfo) != 0)
640
         if (_waccess (valid_pathname, 0) != 0)
642
         {
641
         {
643
            wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"jpeg");
642
            wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"jpeg");
644
            if (_wstat (valid_pathname, &fileinfo) != 0)
643
            if (_waccess (valid_pathname, 0) != 0)
645
            {
644
            {
646
               wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"png");
645
               wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"png");
647
               if (_wstat (valid_pathname, &fileinfo) != 0)
646
               if (_waccess (valid_pathname, 0) != 0)
648
               {
647
               {
649
                  wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"tga");
648
                  wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"tga");
650
                  if (_wstat (valid_pathname, &fileinfo) != 0)
649
                  if (_waccess (valid_pathname, 0) != 0)
651
                  {
650
                  {
652
                     wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"bmp");
651
                     wcscpy_s (&valid_pathname[length - 1], WCHAR_SIZEOF (valid_pathname) - (length - 1), L"bmp");
653
                     if (_wstat (valid_pathname, &fileinfo) != 0)
652
                     if (_waccess (valid_pathname, 0) != 0)
654
                        return (false); // if none of these extensions match, bomb out
653
                        return (false); // if none of these extensions match, bomb out
655
                  }
654
                  }
656
               }
655
               }
657
            }
656
            }
658
         }
657
         }