Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Unexpected results using al_findnext

This thread is locked; no one can reply to it. rss feed Print
Unexpected results using al_findnext
James Bunting
Member #30
April 2000
avatar

Does anyone have any idea why all of the file names returned by al_findnext using the code below have 8 characters missing from the front of each name?

For example:
"allegrotest2.exe" is "est2.exe" and ".." is gibberish (as the terminator is trimmed.

I am using MSVC 2005 and downloaded the precompiled Allegro binary v4.21 (allegro-msvc80-4.2.1.zip).

This is confusing at everything seems pretty standard with no external code. I get the feeling its something to do with my setup although I can use the rest of Allegro OK.

Thanks in advance, input and output screenies attached!

James

PS: I an running XP Pro 32 bit

1#include <allegro.h>
2 
3#pragma comment(lib, "alleg.lib")
4 
5// ignore libs: libcmt, msvcrt
6 
7#define CL_BLACK makecol(0,0,0)
8#define CL_WHITE makecol(255,255,255)
9 
10#define FONT_H text_height(font)
11 
12 
13void ListFiles( char *path)
14{
15 struct al_ffblk FileInfo;
16 int i;
17 
18 clear_to_color( screen, CL_BLACK);
19 
20 if( al_findfirst( path, &FileInfo, FA_RDONLY | FA_HIDDEN | FA_SYSTEM | FA_LABEL | FA_DIREC | FA_ARCH) == 0)
21 {
22 i=0;
23 do
24 {
25 textprintf_ex( screen, font, 10, 10 + (i * FONT_H), CL_WHITE, -1, "%s", FileInfo.name);
26 
27 if (*allegro_errno != 0)
28 return;
29 
30 i++;
31 
32 } while (al_findnext( &FileInfo) == 0);
33
34 textprintf_ex( screen, font, 10, SCREEN_H - FONT_H, CL_WHITE, -1, "%d files found", i);
35 }
36 else
37 {
38 textprintf_ex( screen, font, 10, 10, CL_WHITE, -1, "No files found");
39 }
40 
41 al_findclose( &FileInfo);
42}
43 
44int main( int argc, char *argv[])
45{
46 allegro_init();
47 install_timer();
48 install_keyboard();
49 set_keyboard_rate( 900, 50);
50 install_mouse();
51 
52 if( set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) != 0)
53 return 1;
54 
55 ListFiles("debug\*.*");
56 while( !key[KEY_ESC]);
57 
58 return 0;
59}
60END_OF_MAIN()

Matthew Leverton
Supreme Loser
January 1999
avatar

I ran your program as-is on the unstable 4.9 branch and it worked correctly. Could you attach your EXE?

James Bunting
Member #30
April 2000
avatar

Sure I uploaded the whole project in a zip file.

Probably got my headers mixed up from an older Allegro version or something (I did a few compile attempts before downloading the binary), I will run an fc.exe on the downloaded and installed headers.

FIXED IT!

I had the wrong version of alleg42.dll in my system32 folder.

Now I feel stupid for wasting your time!

James

Matthew Leverton
Supreme Loser
January 1999
avatar

Your supplied EXE works fine for me too. (I'm probably using the same alleg42.dll.)

You could double check that you're using the 4.2.1 DLL, but you really should get an error message if it is mismatached.

Edit: I guess that was it.

James Bunting
Member #30
April 2000
avatar

Thanks for speedy service (frankly amazing). I guess the fact that the DLLs have the same names but are different can often cause issues.

When I deploy my apps I put the DLL in the game folder (not system32 thankfully). I keep the "current" Allegro DLL in system32 for general Allegro development.

Thanks again, on with coding the masterpeice...

James

Go to: