« Return to Thread: lstat(), lstat64()

lstat(), lstat64()

by Linux-48 :: Rate this Message:

| View in Thread

I noticed that the lstat() and lstat64() functions and S_ISLNK flag are
not available with MinGW.


I used this workaround:

#define __MSVCRT_VERSION__  0x0601 /* or greater */
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#include <unistd.h>
#include <windef.h>
#include <windows.h>
#include <tchar.h>

void find_link(void)
{
WIN32_FIND_DATA entry;
HANDLE cwd = INVALID_HANDLE_VALUE;

    chdir("c:\testdir"); /* Directory to be searched for */
                         /* linked files and linked folders */

    cwd = FindFirstFile(".\\*", &entry);
    if (INVALID_HANDLE_VALUE == cwd)
    {
        return;
    }

    do
    {
       if( entry.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
      {
          printf("Link: %s\n", entry.cFileName);
      }
    } while (FindNextFile(cwd, &entry) != 0);

    FindClose(cwd);
}


Regards,

Hans


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
MinGW-users mailing list
MinGW-users@...

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@...?subject=unsubscribe

 « Return to Thread: lstat(), lstat64()