⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfiles.prg

📁 MSComm控件资料,Visual Basic 6.0(以下简称VB) 是一种功能强大、简单易学的程序设计语言。它不但保留了原先Basic语言的全部功能
💻 PRG
📖 第 1 页 / 共 2 页
字号:
*************************************************
DEFINE CLASS CFileRepository AS SESSION OLEPUBLIC
*************************************************
	PROTECTED cFileTable, cMessagingType, ;
		cTranslatorClass, oTranslator, aFiles, ;
		nFileCount, cOldDeleted, cOldSafety, ;
		Version
	

	Version = "1.1"
	*-- The name of the table that holds the
	*-- list of files.
	cFileTable 			= "CN_FILES.DBF"

	*-- Determines how GetXXX() methods will return
	*-- information. Valid types are Array, XML,
	*-- and ADO. If the type is array, then VFP
	*-- arrays will be returned. If the type is XML
	*-- then XML will be returned. If the type is
	*-- ADO then an ADO recordset will be used. Note:
	*-- this only applies to methods that can return 
	*-- more than one piece of information such as
	*-- GetFileList(). Methods that only return
	*-- one piece of info will use the normal return
	*-- types such as a string, numeric, etc.
	cMessagingType      = "Array"

	*-- The class to use to translate information from one
	*-- format to another. For example, used to translate
	*-- a VFP cursor to XML or ADO or to translate an
	*-- XML string to a VFP cursor.
	cTranslatorClass	= "CCOMUTIL"

	*-- An object reference to the translator class (bridge)
	oTranslator         = NULL

	*-- The number of records in the file table
	nFileCount = 0

	cOldDeleted = ""
	cOldSafety  = ""	
	
	*---------------- Location Section ---------------------
	*} Library: CFILES.PRG
	*} Class:   CFileRepository
	*} Method:  Init()
	*-------------------------------------------------------
	*) Description:  
	*------------------- Usage Section ---------------------
	*$ Scope:		
	*$ Parameters:  
	*$ Usage:		
	*$ Returns:		Logical
	*$ Notes:		
	*-------------------------------------------------------
	*!	Copyright:
	*!		Flash Creative Management, Inc., 1999
	*!		Author: Michael G. Emmons
	*!		Architect: Michael G. Emmons
	*-------------------------------------------------------
	PROCEDURE Init()
		LOCAL lnFiles
		
		THIS.cOldDeleted = SET('DELETED')
		SET DELETED ON
		
		THIS.cOldSafety = SET('SAFETY')
		SET SAFETY OFF
		
		THIS.OpenFileTable()
		lnFiles = THIS.ValidateFileTable()
		THIS.nFileCount = lnFiles
		
		RETURN 
				
	ENDPROC
	*///////////////////////////////////////////////////////	

	*---------------- Location Section ---------------------
	*} Library: CFILES.PRG
	*} Class:   CFileRepository
	*} Method:  OpenFileTable()
	*-------------------------------------------------------
	*) Description: Opens the file table associated with 
	*)	this object. If the table does not exist a new
	*)	one will be created.
	*------------------- Usage Section ---------------------
	*$ Scope:		
	*$ Parameters:  
	*$ Usage:		
	*$ Returns:		Logical
	*$ Notes:		
	*-------------------------------------------------------
	*!	Copyright:
	*!		Flash Creative Management, Inc., 1999
	*!		Author: Michael G. Emmons
	*!		Architect: Michael G. Emmons
	*-------------------------------------------------------
	PROTECTED PROCEDURE OpenFileTable()
		LOCAL llRetVal
		
		llRetVal = .T.
		IF FILE(THIS.cFileTable)
			USE (THIS.cFileTable) EXCLU
			PACK
		ELSE
			llRetVal = THIS.CreateFileTable()
		ENDIF
		
		RETURN llRetVal
				
	ENDPROC
	*///////////////////////////////////////////////////////	

	*---------------- Location Section ---------------------
	*} Library: CFILES.PRG
	*} Class:   CFileRepository
	*} Method:  CreateFileTable()
	*-------------------------------------------------------
	*) Description: Creates a new file table
	*------------------- Usage Section ---------------------
	*$ Scope:		
	*$ Parameters:  
	*$ Usage:		
	*$ Returns:		Logical
	*$ Notes:		
	*-------------------------------------------------------
	*!	Copyright:
	*!		Flash Creative Management, Inc., 1999
	*!		Author: Michael G. Emmons
	*!		Architect: Michael G. Emmons
	*-------------------------------------------------------
	PROTECTED PROCEDURE CreateFileTable()
		LOCAL llRetVal
		
		llRetVal = .T.
		CREATE TABLE (THIS.cFileTable) FREE ;
			(Filename C(50) , FilenameEx c(240) )

		INDEX ON ALLTRIM(Filename)   TAG Filename   OF (JUSTSTEM(THIS.cFileTable))
		INDEX ON ALLTRIM(FilenameEx) TAG FilenameEx OF (JUSTSTEM(THIS.cFileTable))
		INDEX ON DELETED()  		 TAG Cdeleted   OF (JUSTSTEM(THIS.cFileTable))

		RETURN llRetVal
				
	ENDPROC
	*///////////////////////////////////////////////////////	

	*---------------- Location Section ---------------------
	*} Library: CFILES.PRG
	*} Class:   CFileRepository
	*} Method:  ValidateFileTable()
	*-------------------------------------------------------
	*) Description: Ensures that each file in the file table
	*)	exists. Deletes files that do not exist.
	*------------------- Usage Section ---------------------
	*$ Scope:		
	*$ Parameters:  
	*$ Usage:		
	*$ Returns:		Numeric
	*$ Notes:		
	*-------------------------------------------------------
	*!	Copyright:
	*!		Flash Creative Management, Inc., 1999
	*!		Author: Michael G. Emmons
	*!		Architect: Michael G. Emmons
	*-------------------------------------------------------
	PROTECTED PROCEDURE ValidateFileTable()
		LOCAL lnRetVal, lnSelected
		
		lnSelected = SELECT(0)
		SELECT (THIS.cFileTable)
		SCAN
			IF !FILE(FilenameEx)
				DELETE
			ENDIF
		ENDSCAN
		COUNT FOR NOT DELETED() TO lnRetVal
		SELECT (lnSelected)
		
		RETURN lnRetVal
				
	ENDPROC
	*///////////////////////////////////////////////////////	

	*---------------- Location Section ---------------------
	*} Library: CFILES.PRG
	*} Class:   CFileRepository
	*} Method:  AddFile()
	*-------------------------------------------------------
	*) Description:  Adds a file to the filetable. Returns
	*)	true if the file was added.
	*------------------- Usage Section ---------------------
	*$ Scope:		
	*$ Parameters:  tcFilename     - The name of the file to add
	*$				tcFullFilename - The full path and name of the file to add
	*$ Usage:		
	*$ Returns:		Logical
	*$ Notes:		
	*-------------------------------------------------------
	*!	Copyright:
	*!		Flash Creative Management, Inc., 1999
	*!		Author: Michael G. Emmons
	*!		Architect: Michael G. Emmons
	*-------------------------------------------------------
	PROCEDURE AddFile(tcFilename, tcFullFilename)

		LOCAL llRetVal
		
		llRetVal = .F.
		IF FILE(tcFullFilename) AND NOT THIS.ContainsFile(tcFullFilename)
			llRetVal = .T.

			INSERT INTO (THIS.cFileTable) (Filename, FilenameEx) ;
				VALUES (tcFilename, tcFullFilename)
			
			THIS.nFileCount = THIS.nFileCount + 1
		ENDIF

		RETURN llRetVal

	ENDPROC
	*///////////////////////////////////////////////////////	

	*---------------- Location Section ---------------------
	*} Library: CFILES.PRG
	*} Class:   CFileRepository
	*} Method:  RemoveFile()
	*-------------------------------------------------------
	*) Description:  Removes a file from the filetable. Returns
	*)	true if the file was removed.
	*------------------- Usage Section ---------------------
	*$ Scope:		
	*$ Parameters:  tcFullFilename - The full path and name of the file to add
	*$ Usage:		
	*$ Returns:		Logical
	*$ Notes:		
	*-------------------------------------------------------
	*!	Copyright:
	*!		Flash Creative Management, Inc., 1999
	*!		Author: Michael G. Emmons
	*!		Architect: Michael G. Emmons
	*-------------------------------------------------------
	PROCEDURE RemoveFile(tcFullFilename)

		LOCAL llRetVal
		
		llRetVal = .F.
		IF THIS.ContainsFile(tcFullFilename)
			llRetVal = .T.
			DELETE IN (THIS.cFileTable)

			THIS.nFileCount = THIS.nFileCount - 1
		ENDIF

		RETURN llRetVal

	ENDPROC
	*///////////////////////////////////////////////////////	

	*---------------- Location Section ---------------------
	*} Library: CFILES.PRG
	*} Class:   CFileRepository
	*} Method:  ContainsFile()
	*-------------------------------------------------------
	*) Description:  Returns true if the full path and file
	*)	passed in the parameter already exist in the file
	*)	table.
	*------------------- Usage Section ---------------------
	*$ Scope:		
	*$ Parameters:  tcFullFilename - The full path and name of the file to check
	*$ Usage:		
	*$ Returns:		Logical
	*$ Notes:		
	*-------------------------------------------------------
	*!	Copyright:
	*!		Flash Creative Management, Inc., 1999
	*!		Author: Michael G. Emmons
	*!		Architect: Michael G. Emmons
	*-------------------------------------------------------
	PROCEDURE ContainsFile(tcFullFilename)

		LOCAL llRetVal
		llRetVal = SEEK(tcFullFilename, JUSTSTEM(THIS.cFileTable), "FilenameEx") ;
			AND NOT DELETED()
		
		RETURN llRetVal

	ENDPROC
	*///////////////////////////////////////////////////////	

	*---------------- Location Section ---------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -