示例#1
0
文件: fsusage.c 项目: Vairn/PUAE
int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
{
    struct InfoData *info = (struct InfoData *)AllocVec(sizeof *info, MEMF_ANY);
    int result = -1;

    if (info) {
	BPTR lock = Lock (path, SHARED_LOCK);
	if (lock) {
	    if (Info (lock, info)) {
		fsp->fsu_blocks = adjust_blocks (info->id_NumBlocks,
						 info->id_BytesPerBlock,
						 512);
		fsp->fsu_bfree = fsp->fsu_bavail =
				  adjust_blocks (info->id_NumBlocks - info->id_NumBlocksUsed,
						 info->id_BytesPerBlock,
						 512);
		fsp->fsu_files = fsp->fsu_ffree = -1;

		result = 0;
	    }
	    UnLock (lock);
	}
	FreeVec (info);
    }
    return result;
}
示例#2
0
文件: fsusage.c 项目: Vairn/PUAE
int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
{
    char buf2[MAX_DPATH];
    DWORD SectorsPerCluster;
    DWORD BytesPerSector;
    DWORD NumberOfFreeClusters;
    DWORD TotalNumberOfClusters;

	GetFullPathName (path, sizeof buf2, buf2, NULL);

    buf2[3] = 0;

    if (!GetDiskFreeSpace (buf2, &SectorsPerCluster, &BytesPerSector,
			   &NumberOfFreeClusters, &TotalNumberOfClusters)) {
		/* lasterror = GetLastError ();*/
		return -1;
    }

    /* HACK ALERT! WinNT returns 0 in TotalNumberOfClusters for an audio-CD, which calls the GURU! */
    if ((TotalNumberOfClusters == 0) && (GetDriveType (buf2) == DRIVE_CDROM))
		TotalNumberOfClusters = 327680;

    BytesPerSector *= SectorsPerCluster;
    fsp->fsu_blocks = adjust_blocks (TotalNumberOfClusters, BytesPerSector, 512);
    fsp->fsu_bavail = adjust_blocks (NumberOfFreeClusters, BytesPerSector, 512);

    return 0;
}
示例#3
0
void frame::copy_to( char* sp,
                     char* caller,
                     char* pc,
                     bool adjust) {

  sparc_sp *new_sp = (sparc_sp*)sp;

  if (adjust) {
    // make sure all memoized blocks exist, then adjust their scope
    abstract_vframe* callee = NULL;
    OopOopTable* dummy = EMPTY;
    for ( abstract_vframe* vf = new_vframe(this);
          vf  &&  vf->fr == this;
          callee = vf,  vf = vf->sender()) {
      vf->createBlocks(callee, dummy);
    }
    frame* new_f = new_sp->as_callers_frame();
    ResourceMark rm; // for RegisterLocator
    adjust_blocks(block_scope_of_home_frame(), new_f, RegisterLocator::for_frame(new_f));
  }
  copy_oops(my_sp()->as_oops(), new_sp->as_oops(), frame_size());

  new_sp->set_link( (sparc_fp*) caller );
  new_sp->set_return_addr( pc );
}
示例#4
0
void frame::copy_to( char* sp,
                     char* caller,
                     char* pc,
                     bool adjust) {

  frame* new_f = (frame*)sp;
  if (SpendTimeForDebugging)
    warning("untested frame::copy_to:"); // need SIC to test this

  if (adjust) {
    // make sure all memoized blocks exist, then adjust their scope
    abstract_vframe* callee = NULL;
    OopOopTable* dummy = EMPTY;
    for ( abstract_vframe* vf = new_vframe(this);
          vf  &&  vf->fr == this;
          callee = vf,  vf = vf->sender()) {
      vf->createBlocks(callee, dummy);
    }
    ResourceMark rm; // for RegisterLocators
    adjust_blocks(block_scope_of_home_frame(), new_f, RegisterLocator::for_frame(new_f) );
  }
  copy_oops( (oop*)this, (oop*)new_f, frame_size());

  my_sp()->set_link( ((frame*)caller)->my_sp() );
  set_return_addr( pc );
}
示例#5
0
文件: fsusage.c 项目: engur/PUAE
int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
{
	int result = -1;
	dev_t device = dev_for_path (path);

	if (device >0) {
		fs_info info;
		if (fs_stat_dev (device, &info) == 0) {
			fsp->fsu_blocks = adjust_blocks (info.total_blocks, info.block_size, 512);
			fsp->fsu_bfree = fsp->fsu_bavail = adjust_blocks (info.free_blocks, info.block_size, 512);
			fsp->fsu_files = info.total_nodes;
			fsp->fsu_ffree = info.free_nodes;
			result = 0;
		}
	}
	return result;
};
示例#6
0
文件: fsusage.c 项目: engur/PUAE
int get_fs_usage (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp)
{
//	TCHAR buf2[MAX_DPATH];
//	ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;

    struct InfoData *info = (struct InfoData *)AllocVec(sizeof *info, MEMF_ANY);
    int result = -1;

    if (info) {
		BPTR lock = Lock (path, SHARED_LOCK);
		if (lock) {
		    if (Info (lock, info)) {
				fsp->fsu_blocks = adjust_blocks (info->id_NumBlocks, info->id_BytesPerBlock, 512);
				fsp->fsu_bfree = fsp->fsu_bavail = adjust_blocks (info->id_NumBlocks - info->id_NumBlocksUsed, info->id_BytesPerBlock, 512);
				fsp->fsu_files = fsp->fsu_ffree = -1;
				result = 0;
			}
			UnLock (lock);
		}
		FreeVec (info);
	}
	return result;
}