Guidance
指路人
g.yi.org
software / rapidq / Examples / Tools - IDE, Designer, Builder / FreeQ IDE src / inc ide / IDE_FileOps.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'=======================================================================|
'Routines from Fileops to manipulate file names and paths.         |
'  QUOTE - Returns a quoted string                                      |
'  STRIPPATH - Returns file path (without file name)                    |
'  STIPFILENAME - Returns file name (without path)                      |
'  STRIPFILEEXT - Returns file extension (like ".exe", ".html" etc.)    |
'  FILENAMENOEXT - Returns file name without extension                  |
'  FULLPATHNOEXT - Returns full path without file extension             |
'  BROWSEFORFOLDERS,  BROWSEFORFILE not used for efficiency with native code
'=======================================================================|


     $IFNDEF __FILEOPS_INC
      $DEFINE __FILEOPS_INC


    '===============================================================================
    '# QUOTE : Returns a quoted string
      FUNCTION Quote(StringToQuote AS STRING) AS STRING
       StringToQuote = CHR$(34) + StringToQuote + CHR$(34)
       Result = REPLACESUBSTR$(stringtoquote , CHR$(34) + CHR$(34) , CHR$(34))
      END FUNCTION

    '===============================================================================
    '# STRIPPATH : Returns file path (without file name)
      FUNCTION StripPath(fullname AS STRING) AS STRING
       Result = LEFT$(fullname , rinstr(fullname , "\"))
      END FUNCTION

    '===============================================================================
    '# STRIPFILENAME : Returns file name (without path)
      FUNCTION StripFileName(fullname AS STRING) AS STRING
       Result = RIGHT$(fullname , LEN(fullname) - rinstr(fullname , "\"))
      END FUNCTION

    '===============================================================================
    '# STRIPFILEEXT : Returns file extension (like ".exe", ".html" etc.)
      FUNCTION StripFileExt(fullname AS STRING) AS STRING
       Result = RIGHT$(fullname , LEN(fullname) - rinstr(fullname , ".") + 1)
      END FUNCTION

    '===============================================================================
    '# FILENAMENOEXT : Returns file name without extension
      FUNCTION FileNameNoExt(fullname AS STRING) AS STRING
       fullname = RIGHT$(fullname , LEN(fullname) - rinstr(fullname , "\"))
       Result = LEFT$(fullname , rinstr(fullname , ".") - 1)
      END FUNCTION

    '===============================================================================
    '# FULLPATHNOEXT : Returns full path without file extension
      FUNCTION FullPathNoExt(fullname AS STRING) AS STRING
       Result = LEFT$(fullname , rinstr(fullname , ".") - 1)
      END FUNCTION

    '===============================================================================
    '# C_Style : Returns "slashed" path from a "backslashed" one
      FUNCTION C_Style(fullname AS STRING) AS STRING
       fullname = REPLACESUBSTR$(fullname , "\\" , "\")
       Result = REPLACESUBSTR$(fullname , "\" , "/")
      END FUNCTION


    '===============================================================================
    '# SYSDIR : Retrieves windows shell directories
    '-------------------------|
    'Allowed values for dir  |
    '----------------------------------------------------------------------------|
    'Desktop                 | Templates               | AppData                 |
    'Start Menu              | Programs                | Startup                 |
    'Fonts                   | SendTo                  | Recent                  |
    'Favorites               | Cache                   | Cookies                 |
    'History                 | NetHood                 | Personal                |
    'PrintHood               | Local AppData           | My Pictures             |
    'Administrative Tools    |                         |                         |
    '----------------------------------------------------------------------------|
      FUNCTION SysDir(dir AS STRING) AS STRING
       DIM fo_reg AS QREGISTRY
       fo_reg.RootKey = &H80000001
       fo_reg.openkey("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" , 0)
       Result = fo_reg.readstring(dir) + "\"
      END FUNCTION


'-- ***********************************************************************'
      SUB FileCopy(FileSrc$ AS STRING, FileDst$ AS STRING)
    'Andrew Shelkovenko dec 2003
    'Copy FileSrc$ to FileDst$
    'if path dest is not exists - create it.

       DIM FileSrc AS QFILESTREAM
       DIM FileDst AS QFILESTREAM

'     DEFSTR dr$ = StripPath(FileDst$)
'     IF dr$ <> "" THEN
'         MKSubDir dr$
'         IF DIREXISTS(dr$) = 0 THEN SHOWMESSAGE("Cannot create directory " + dr$)
'         EXIT SUB
'     END IF

       FileSrc.OPEN(FileSrc$ , fmOpenRead)
       FileDst.OPEN(FileDst$ , fmCreate)
       FileDst.CopyFrom(FileSrc , 0)
       FileSrc.CLOSE
       FileDst.CLOSE
      END SUB

     $ENDIF



     FUNCTION TRIM$(Str AS STRING) AS STRING  'Clean spaces in one string
      Result = LTRIM$(RTRIM$(Str))
     END FUNCTION




掌柜推荐
 
 
¥1,420.00 ·
 
 
¥950.00 ·
 
 
¥288.00 ·
 
 
¥738.00 ·
 
 
¥397.00 ·
 
 
¥750.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-12-07 21:18:03