Beispiel #1
0
bool os_fstat(int fd, const char* path, pony_stat_t* p)
{
#if defined(PLATFORM_IS_WINDOWS)
  HANDLE h = (HANDLE)_get_osfhandle(fd);
  BY_HANDLE_FILE_INFORMATION fa;

  if(!GetFileInformationByHandle(h, &fa))
    return false;

  struct __stat64 st;

  if(_fstat64(fd, &st) != 0)
    return false;

  windows_stat(path, p, &st, fa.dwFileAttributes,
    &fa.ftLastAccessTime, &fa.ftLastWriteTime, &fa.ftCreationTime);

  return true;
#elif defined(PLATFORM_IS_POSIX_BASED)
  (void)path;
  struct stat st;

  if(fstat(fd, &st) != 0)
    return false;

  unix_stat(p, &st);
  return true;
#endif
}
Beispiel #2
0
bool os_stat(const char* path, pony_stat_t* p)
{
#if defined(PLATFORM_IS_WINDOWS)
  WIN32_FILE_ATTRIBUTE_DATA fa;

  if(!GetFileAttributesEx(path, GetFileExInfoStandard, &fa))
    return false;

  struct __stat64 st;

  if(_stat64(path, &st) != 0)
  {
    // Report a broken symlink with no other information.
    p->symlink = true;
    p->broken = true;
    return true;
  }

  windows_stat(path, p, &st, fa.dwFileAttributes,
    &fa.ftLastAccessTime, &fa.ftLastWriteTime, &fa.ftCreationTime);

  return true;
#elif defined(PLATFORM_IS_POSIX_BASED)
  struct stat st;

  if(lstat(path, &st) != 0)
    return false;

  unix_stat(p, &st);

  if(p->symlink && (stat(path, &st) != 0))
  {
    // Report a broken symlink with everything set except the size.
    p->broken = true;
    p->size = 0;
  }

  return true;
#endif
}
Beispiel #3
0
void factor_vm::primitive_existsp() {
  vm_char* path = untag_check<byte_array>(ctx->pop())->data<vm_char>();
  ctx->push(tag_boolean(windows_stat(path)));
}