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

📄 file.cpp

📁 基于Nuleus操作系统和s3c4510的编写的EFC。已经包含了该EFC的设计说明。这是个实际产品的代码
💻 CPP
字号:
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2003, Ulink Telecom Equipment Co., Ltd. All rights reserved.
//
// File:
//
//    File.cpp
//
// Abstract:
//
//    implementation of the CFile class.
//
// History:
//
//    V1.0	2003-02-26	Alex Duan	Original version.
//
///////////////////////////////////////////////////////////////////////////////

#include "File.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CFile::CFile()
{
	m_nOpenFlags = 0;
	m_nFileSize  = 0;
	m_nPosition	 = 0;
}

CFile::~CFile()
{
	Close(); // Call CFile::Close()
}

///////////////////////////////////////////////////////////////////////////////
// Parameters:
//		lpszFileName	A string that is the name(8.3) of the desired file.
//		nOpenFlags		An UINT that defines the file's access mode.
// Return Value:
//		TRUE if the open was successful; otherwise FALSE. 
// Remarks:
//		Open a file.
BOOL CFile::Open(LPCSTR lpszFileName, UINT nOpenFlags)
{
	UNUSED_ARG(lpszFileName, nOpenFlags);

 	ASSERT_VALID(this);

	return FALSE;
}

///////////////////////////////////////////////////////////////////////////////
// Parameters:
//		lOff	Number of bytes to move the pointer
//		nFrom	Pointer movement mode, must be one of the following values:
//				CFile::begin	Move from the beginning of the file.
//				CFile::current	Move from the current position in the file.
//				CFile::end		Move from the end of the file. lOff: negative
// Return Value:
//		If the requested position is legal, Seek returns the new byte offset
//		from the beginning of the file. Otherwise the return value is undefined.
// Remarks:
//		Repositions the pointer in the previously opened file.
LONG CFile::Seek(LONG lOff, UINT nFrom)
{
	ASSERT_VALID(this);
	ASSERT(nFrom == begin || nFrom == end || nFrom == current);

	switch (nFrom) 
	{
	case begin:
		m_nPosition = lOff;
		break;
	case current:
		m_nPosition += lOff; 
		break;
	case end:
		m_nPosition = m_nFileSize + lOff;
		break;
	default:
		break;
	}
	return m_nPosition;
}

///////////////////////////////////////////////////////////////////////////////
// Return Value:
//		The file pointer as a 32-bit doubleword.
// Remarks:
//		Obtains the current value of the file pointer.
DWORD CFile::GetPosition() const
{
	ASSERT_VALID(this);
	return m_nPosition;
}

void CFile::Close()
{
	ASSERT_VALID(this);

	m_nPosition  = 0;
	m_nFileSize  = 0;
	m_nOpenFlags = 0;
	m_strFileName.Empty();
}

void CFile::SetLength(DWORD dwNewLen)
{
	m_nFileSize = dwNewLen;
}

DWORD CFile::GetLength() const
{
	return m_nFileSize;
}

///////////////////////////////////////////////////////////////////////////////
// Parameters:
//		lpszString	A string to search for
// Remarks:
//		Finds a string inside a text format file.
int CFile::Find(LPCSTR lpszString) const
{
	UNUSED(lpszString);
	return 0;
}

///////////////////////////////////////////////////////////////////////////////
// Parameters:
//		rString	A reference to a CString object that will contain the string 
//				when the function returns.
// Return Value:
//		The number of bytes read from the file.
// Remarks:
//		Read a line of string from the file.
UINT CFile::ReadLine(CString &rString)
{
	UNUSED(rString);
	return 0;
}

///////////////////////////////////////////////////////////////////////////////
// Parameters:
//		lpszString	Specifies a pointer to a buffer containing a null-terminated
//					text string.
// Remarks:
//		Write a line of string to the file. "\r\n" are appended automatically.
void CFile::WriteLine(LPCSTR lpszString)
{
	UNUSED(lpszString);
}

⌨️ 快捷键说明

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