Skip to content

Instantly share code, notes, and snippets.

@jeremyd2019
Created June 4, 2024 00:19
Show Gist options
  • Save jeremyd2019/ac2f00ec448e75c4bd3630926201db19 to your computer and use it in GitHub Desktop.
Save jeremyd2019/ac2f00ec448e75c4bd3630926201db19 to your computer and use it in GitHub Desktop.
use cygwin functions to list windows volume roots as `\0`-delimited cygwin paths
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/cygwin.h>
struct dos_drive_mappings
{
struct mapping
{
struct mapping *next;
size_t doslen;
size_t ntlen;
wchar_t *dospath;
wchar_t *ntdevpath;
} *mappings;
};
void main (void)
{
struct dos_drive_mappings *ddm = (struct dos_drive_mappings*)cygwin_internal(CW_ALLOC_DRIVE_MAP);
for(struct mapping * p = ddm->mappings; p != NULL; p = p->next)
{
char * cygpath = cygwin_create_path(CCP_WIN_W_TO_POSIX, p->dospath);
fwrite(cygpath, sizeof(char), strlen(cygpath) + 1, stdout);
free(cygpath);
}
cygwin_internal(CW_FREE_DRIVE_MAP, ddm);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment