/* getvol.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */
/* (rs) remove os/2 functions to build crtdll with sys-lib */

#include <stdlib.h>
#include <string.h>
#include <emx/thread.h>
#include <emx/syscalls.h>

char *_getvol (char drive)
{
  static char result[12];
  static struct _find find;
  char mask[7];

  if (drive == 0)
    drive = _getdrive ();
  if (drive >= 'a' && drive <= 'z')
    drive += 'A' - 'a';
  if (!(drive >= 'A' && drive <= 'Z'))
    return NULL;

  mask[0] = drive;
  strcpy (mask + 1, ":\\*.*");
  if (__findfirst (mask, _A_VOLID, &find) != 0)
    return NULL;
  strcpy (result, find.name);

  return result;
}
