コード例 #1
0
ファイル: os2io.c プロジェクト: Akin-Net/mozilla-central
PRInt32
_PR_MD_RENAME(const char *from, const char *to)
{
   PRInt32 rc;
    /* Does this work with dot-relative pathnames? */
    if ( (rc = DosMove((char *)from, (char *)to)) == NO_ERROR) {
        return 0;
    } else {
		_PR_MD_MAP_RENAME_ERROR(rc);
        return -1;
    }
}
コード例 #2
0
ファイル: lxapid_cmd.c プロジェクト: OS2World/DRV-LXAPI32
//------------------------------ CMD_LXAFS_Rename ------------------------------
void CMD_LXAFS_Rename(HFILE hFile,LXIOCPA_DMN_CMDPARMPACKET* pParam
                      ,PLXTWONAMESTRUCT tn)
{
 char* oldname=tn->name1;
 char* newname=tn->name2;
 pParam->rc=DosMove(oldname,newname);
 if(!pParam->rc)
 {
  FILESTATUS4 fs4;
  pParam->rc=DosQueryPathInfo(newname,FIL_QUERYEASIZE,&fs4,sizeof(FILESTATUS4));
  if(!pParam->rc)
   if(fs4.attrFile&FILE_DIRECTORY)
    pParam->rc=lxafs_linkinfo_correction(newname,oldname);
 }
}
コード例 #3
0
ファイル: DM.CPP プロジェクト: OS2World/DEV-SAMPLES-ICLUI
Boolean DMDatei::targetDrop (IDMTargetDropEvent &e)
{
        Verzeichnis *zv = (Verzeichnis *)e.object ();
        IDMTargetOperation *op = targetOperation ();

        IDMItem::Handle h = sourceItemFor (this);
        IDMItem *ci = (IDMItem *)h;
        IString Ziel = zv->path () + "\\" + ci->sourceName ();
        IString Quelle = ci->containerName () + "\\" + ci->sourceName ();

        if ( op->operation () == IDMOperation::copy )
        {
                DosCopy (Quelle, Ziel, 1);
        }
        if ( op->operation () == IDMOperation::move )
        {
                DosMove (Quelle, Ziel);
        }
        if ( op->operation () == IDMOperation::link )
        {
                // OS/2 Filesysteme kennen leider keine link
        }
        return true;
}
コード例 #4
0
int main(VOID) {



   /* Create a file "first.dat" in the current directory */



   rc = DosOpen("first.dat", &hfFileHandle, &ulAction,

                100L, FILE_NORMAL, FILE_CREATE | OPEN_ACTION_OPEN_IF_EXISTS,

                OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE, 0L);

   if (rc != NO_ERROR) {

      printf("DosOpen error: return code = %u\n", rc);

      return 1;        }



   rc = DosClose(hfFileHandle);          /* Close the file (it contains junk) */

   if (rc != NO_ERROR) {

      printf("DosClose error: return code = %u\n", rc);

      return 1;        }



   /* Create a new subdirectory within the current directory */



   rc = DosCreateDir(uchNewDirName, peaop2NewDirAttribute);

   if (rc != NO_ERROR) {

     printf("DosCreateDir error: return code = %u\n", rc);

     return 1;         }



   /* Move the file "first.dat" from the current directory to

      the new directory "newdir", and rename it "second.dat" */



   rc = DosMove(uchOldPathName, uchNewPathName);

   if (rc != NO_ERROR) {

     printf("DosMove error: return code = %u\n", rc);

     return 1;

   } else {

     printf("DosMove:  Move from %s to %s complete.\n",

             uchOldPathName, uchNewPathName); }



 return NO_ERROR;

}
コード例 #5
0
ファイル: localos2.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalRename( char *from, char *to )
/**************************************/
{
    return( StashErrCode( DosMove( from, to, 0 ), OP_LOCAL ) );
}
コード例 #6
0
ファイル: cfile.c プロジェクト: OS2World/APP-INTERNET-PwICQ
 int ICQAPI ishare_updateControlFile(ISHARED_CONFIG *cfg, char *md5, ULONG fileKey, ULONG begin, ULONG offset)
 {
    static const char *env[] = { "ishare.incoming", "ishare", "incoming", "tmp", "TMP", NULL };

    char	          keyPath[0x0100];
    char	          *keyName;
    char              buffer[0x0200];
    char              *ptr      = NULL;
    FILE              *hFile;
    BOOL              complete	= FALSE;
    int               f;
    ISHARE_CTL_HEADER h;
    ISHARE_CTL_RECORD r;

    DBGMessage("Updating control-file");

    keyName = ishare_makeControlFilePath(cfg, keyPath);
    sprintf(keyName,"%08lx.ctl",fileKey);

    hFile = fopen(keyPath, "r+b");

    if(!hFile)
    {
       log(cfg,"Error opening control file");
       return 1;
    }

    fseek(hFile, 0L, SEEK_SET);

    if(fread(&h,sizeof(h),1,hFile) != 1)
    {
       log(cfg,"Error reading control file");
       perror(buffer);
       return 2;
    }

    if(h.sz != sizeof(ISHARE_CTL_HEADER))
    {
       DBGMessage("Invalid control file");
       perror(buffer);
       return 3;
    }

    loadString(cfg,"incoming","",buffer,0xFF);

    for(f=0;!*buffer && env[f];f++)
    {
       if(getenv(env[f]))
          strncpy(buffer,getenv(env[f]),0xFF);
    }

    DBGMessage(buffer);
    if(*buffer)
    {
       ptr = buffer+strlen(buffer);
#ifdef linux
       if(*(ptr-1) != '/')
          *(ptr++) = '/';
#else
       if(*(ptr-1) != '\\')
          *(ptr++) = '\\';
#endif

    }

    DBGMessage(buffer);

    DBGTrace(h.szFilename);

    if(h.szFilename > (0x01ff - strlen(buffer)))
    {
       log(cfg,"File name is too large");
       return 4;
    }

    if(fread(ptr,h.szFilename,1,hFile) != 1)
    {
       log(cfg,"Error reading control file");
       return 5;
    }

    DBGMessage(buffer);

    if(!begin && offset == h.fileSize)
    {
       log(cfg,"File was received in one transfer");

       for(f=0;f<16 && h.md5[f] == md5[f];f++);

       if(f != 16)
       {
          log(cfg,"MD5 mismatch");
          h.status = 1;
       }
       else
       {
          h.status = 2;
          complete = TRUE;
#ifdef __OS2__
          sprintf(keyName,"%08lx.dat",fileKey);
          ishare_SetEA(keyPath, "MD5", md5);
#endif
       }
    }
    else
    {
       memset(&r,0,sizeof(ISHARE_CTL_RECORD));
       r.sz = sizeof(r);

       for(f=0;f<16;f++)
          r.md5[f] = md5[f];

       r.time  = time(NULL);
       r.begin = begin;
       r.end   = offset;

       fseek(hFile, 0L, SEEK_END);

       if(fwrite(&r,sizeof(r),1,hFile) != 1)
       {
          log(cfg,"Error writing control-file record");
       }

    }

    fseek(hFile, 0L, SEEK_SET);

    if(fwrite(&h,sizeof(h),1,hFile) != 1)
    {
       log(cfg,"Error writing control-file header");
       fclose(hFile);
       return 7;
    }

    fclose(hFile);

    if(complete)
    {
       sprintf(keyName,"%08lx.dat",fileKey);

       DBGMessage(buffer);
       DBGMessage(keyPath);

#ifdef __OS2__
       if(DosMove(keyPath,buffer))
       {
          CHKPoint();
          if(DosCopy(keyPath,buffer,DCPY_EXISTING ))
          {
             if(DosDelete(keyPath))
                log(cfg,"Failure removing temporary file");
          }
          else
          {
             log(cfg,"Failure copying temporary file");
             return 6;
          }
       }

#else
       if(rename(keyPath,buffer))
       {
          log(cfg,"Failure renaming temporary file");
          return 6;
       }

#endif

       DBGMessage(keyPath);
       sprintf(keyName,"%08lx.ctl",fileKey);
       remove(keyPath);
    }


    return 0;
 }
コード例 #7
0
ファイル: localos2.c プロジェクト: Azarien/open-watcom-v2
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
}
コード例 #8
0
ファイル: lxapid_cmd.c プロジェクト: OS2World/DRV-LXAPI32
//-------------------------------- CMD_DosMove ---------------------------------
void CMD_DosMove(HFILE hFile,LXIOCPA_DMN_CMDPARMPACKET* pParam
                 ,PLXTWONAMESTRUCT tn)
{
 pParam->rc=DosMove(tn->name1,tn->name2);
}
コード例 #9
0
ファイル: util_io.c プロジェクト: svn2github/uhexen2
int Q_rename (const char *oldp, const char *newp)
{
	APIRET rc = DosMove(oldp, newp);
	return (rc == NO_ERROR)? 0 : -1;
}