Skip to main content.
home | support | download

Back to List Archive

Re: Bug?

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Wed Jul 31 2002 - 20:12:36 GMT
At 12:45 PM 07/31/02 -0700, Bill Moseley wrote:
>It's seems like it happens only with share names.

Hum.  I had an old gcc installed on a windows machine and I just tried the
code below, and it seems to work as expected.  Yet something's not working
when the code runs in swish (which I can't build under windows).

C:\>gcc stat.c

C:\>a \\mardy\moseley\swish-e\configure
hello \\mardy\moseley\swish-e\configure
directory 0
file 1

C:\>a \\mardy\moseley\swish-e\
hello \\mardy\moseley\swish-e\
directory 1
file 0

C:\>a \\mardy\moseley\
hello \\mardy\moseley\
directory 1
file 0

C:\>a \\mardy\moseley
hello \\mardy\moseley
directory 1
file 0

It also works using forward slash instead.

Yet:

E:\Program Files\SWISH-E25-3-22>swish-e -i //mardy/moseley
Indexing Data Source: "File-System"
Indexing "//mardy/moseley"

Warning: Invalid path '//mardy/moseley': No such file or directory

Does the win32 build of swish mess with the stat calls?

#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>

int     isdirectory(char *path)
{
    struct stat stbuf;

    if (stat(path, &stbuf))
        return 0;
    return ((stbuf.st_mode & S_IFMT) == S_IFDIR) ? 1 : 0;
}

/* Is a file a regular file?
*/

int     isfile(char *path)
{
    struct stat stbuf;

    if (stat(path, &stbuf))
        return 0;
    return ((stbuf.st_mode & S_IFMT) == S_IFREG) ? 1 : 0;
}


int main(int argc, char **argv)
{
    printf("directory %d\n", isdirectory( argv[1] ));
    printf("file %d\n", isfile( argv[1] ));
}






-- 
Bill Moseley
mailto:moseley@hank.org
Received on Wed Jul 31 20:16:07 2002