示例#1
0
bool LocalInteractive( sys_handle fh )
/************************************/
{
    APIRET type;
    APIRET flags;

    //NYI: really should convert fh to sys_handle, but I know that it's
    // a one-to-one mapping
#ifdef _M_I86
    if( DosQHandType( fh, &type, &flags ) ) {
#else
    if( DosQueryHType( fh, &type, &flags ) ) {
#endif
        return( false );
    }
    if( type == 1 ) {   /* device type */
        return( true );
    }
    return( false );
}

void LocalGetBuff( char *buff, unsigned size )
/********************************************/
{
    struct _STRINGINBUF length;

    if( size > UCHAR_MAX ) {
        size = UCHAR_MAX;
    }
    length.cb = size;
    length.cchIn = 0;
    if( KbdStringIn( buff, &length, 0, 0 ) ) {
        buff[0] = '\r';
        buff[1] = NULLCHAR;
        return;
    }
    buff[length.cchIn] = NULLCHAR;
}

error_handle LocalRename( const char *from, const char *to )
/**********************************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosMove( from, to, 0 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosMove( from, to ), OP_LOCAL ) );
#endif
}

error_handle LocalMkDir( const char *name )
/*****************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosMkDir( name, 0 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosCreateDir( name, NULL ), OP_LOCAL ) );
#endif
}

error_handle LocalRmDir( const char *name )
/*****************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosRmDir( name, 0 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosDeleteDir( name ), OP_LOCAL ) );
#endif
}

error_handle LocalSetDrv( int drv )
/*********************************/
{
#ifdef _M_I86
    return( StashErrCode( DosSelectDisk( drv + 1 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosSetDefaultDisk( drv + 1 ), OP_LOCAL ) );
#endif
}

int LocalGetDrv( void )
/*********************/
{
    APIRET    drive;
    ULONG     map;

#ifdef _M_I86
    if( DosQCurDisk( &drive, &map ) ) {
#else
    if( DosQueryCurrentDisk( &drive, &map ) ) {
#endif
        return( -1 );
    }
    return( drive - 1 );
}

error_handle LocalSetCWD( const char *name )
/******************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosChDir( name, 0 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosSetCurrentDir( name ), OP_LOCAL ) );
#endif
}

long LocalGetFileAttr( const char *name )
/***************************************/
{
#ifdef _M_I86
    USHORT attr;

    if( DosQFileMode( name, &attr, 0 ) ) {
        return( -1L );
    }
    return( attr );
#else
    FILESTATUS3 fileinfo;

    if( DosQueryPathInfo( name, FIL_STANDARD, &fileinfo, sizeof( fileinfo ) ) ) {
        return( -1L );
    }
    return( fileinfo.attrFile );
#endif
}
示例#2
0
unsigned LocalSetCWD( char *name )
/****************************/
{
    return( StashErrCode( DosChDir( name, 0 ), OP_LOCAL ) );
}
示例#3
0
MRESULT EXPENTRY ChangeCurDirWndProc(HWND hDlg, ULONG Msg,
				     MPARAM mp1, MPARAM mp2)

{
    SHORT DriveId, DirId;
    CHAR HlpStr[CCHMAXPATH];
    ULONG DriveMap;
    ULONG PathLen;
    APIRET rc;

    switch (Msg)
    {
    case WM_INITDLG:
/*--- save current drive/dir ---*/

	PathLen = CCHMAXPATH;

	if (DosQCurDisk(&SaveCurDisk, &DriveMap) ||
		DosQCurDir(SaveCurDisk, (PUCHAR)SaveCurDir, &PathLen))
	{
	    DosBeep(1000, 1000);
	    WinDismissDlg(hDlg, FALSE);
	    break;
	}

	if (PathLen == 0)
	    strcpy(SaveCurDir, "\\");
	else
	{
	    memmove(&SaveCurDir[1], SaveCurDir, strlen(SaveCurDir) + 1);
	    SaveCurDir[0] = '\\';
	}

	WinSendDlgItemMsg(hDlg, TID_CD_PATH, EM_SETTEXTLIMIT,
			  MPFROMSHORT(CCHMAXPATH), 0L);

	if (_FillDriveLb(hDlg))
	{
	    DosBeep(1000, 1000);
	    WinDismissDlg(hDlg, FALSE);
	    break;
	}

	CenterDialog(hWndFrame, hDlg);

	WinSetFocus(HWND_DESKTOP, WinWindowFromID(hDlg, LID_CD_DIRS));
	return ((MRESULT) TRUE);
	break;

    case WM_CONTROL:
	switch (SHORT1FROMMP(mp1))
	{
	case LID_CD_DRIVES:
	    if (SHORT2FROMMP(mp1) == LN_ENTER)
	    {
		DriveId =
		    SHORT1FROMMR(WinSendMsg(WinWindowFromID(hDlg, LID_CD_DRIVES),
					    LM_QUERYSELECTION,
					    MPFROMSHORT(LIT_FIRST), NULL));

		WinSendMsg(WinWindowFromID(hDlg, LID_CD_DRIVES), LM_QUERYITEMTEXT,
			   MPFROM2SHORT(DriveId, CCHMAXPATH),
			   MPFROMP(HlpStr));

		SelectedDrive = (USHORT) HlpStr[1] - 64;
		DosSelectDisk(SelectedDrive);

		_FillDirLb(hDlg, SelectedDrive);
	    }
	    break;

	case LID_CD_DIRS:
	    if (SHORT2FROMMP(mp1) == LN_ENTER)
	    {
		DirId =
		    SHORT1FROMMR(WinSendMsg(WinWindowFromID(hDlg, LID_CD_DIRS),
					    LM_QUERYSELECTION,
					    MPFROMSHORT(LIT_FIRST), NULL));

		WinSendMsg(WinWindowFromID(hDlg, LID_CD_DIRS), LM_QUERYITEMTEXT,
			   MPFROM2SHORT(DirId, CCHMAXPATH),
			   MPFROMP(HlpStr));

		if (strncmp(HlpStr, " <root", 6) == 0)
		    strcpy(HlpStr, "\\");

		if (DosChDir(HlpStr))
		    DosBeep(1000, 1000);

		_FillDirLb(hDlg, SelectedDrive);
	    }
	    break;
	}
	break;

    case WM_COMMAND:
	switch (SHORT1FROMMP(mp1))
	{
	case DID_OK:
	    if (FileSelected)
	    {
		rc = WinMessageBox(HWND_DESKTOP, hDlg, "Refresh tree window?",
				   ApplTitle, 0, MB_YESNO |
				   MB_ICONQUESTION | MB_APPLMODAL);

		if (rc == MBID_YES)
		    WinPostMsg(hWndClient, WUM_START_REBUILD, 0L, 0L);
		else
		    WinInvalidateRect(hWndClient, NULL, FALSE);
	    }
	    else
		WinInvalidateRect(hWndClient, NULL, FALSE);

	    WinDismissDlg(hDlg, TRUE);
	    break;

	case DID_CANCEL:
	    if (DosSelectDisk(SaveCurDisk) ||
		    DosChDir(SaveCurDir))
		DosBeep(1000, 1000);

	    WinInvalidateRect(hWndClient, NULL, FALSE);
	    WinDismissDlg(hDlg, FALSE);
	    break;
	}
	break;

    default:
	return WinDefDlgProc(hDlg, Msg, mp1, mp2);
	break;
    }

    return NULL;
}