hide_fat32.cpp

来自「fat file system api in VC」· C++ 代码 · 共 75 行

CPP
75
字号
// Hide_FAT32.cpp: implementation of the Hide_FAT32 class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FS.h"
#include "Hide_FAT32.h"
#include <afxtempl.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

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

Hide_FAT32::Hide_FAT32(char sPath[]):FAT((const char*)sPath)
{
	int n=strlen(sPath);
    pPath=new char[n];
    if(!pPath)
	{
		MessageBox(NULL,"隐藏失败(内存分配错误)","错误",MB_ICONSTOP);;
	}
	CopyElements(pPath,sPath,n);
	if(pPath[n-1]==0x5C)
	{
		pPath[n-1]=0;
	}
}

Hide_FAT32::~Hide_FAT32()
{
    if(pPath)
	{
		delete[] pPath;
	}
}

BOOL Hide_FAT32::Hide(int Flag)//set Flag for use in Show()
{
    Directory_FAT EntryContent;
	if(!GetEntryContent(pPath,EntryContent))
	{
		return FALSE;
	}

	EntryContent.Volume=Flag;
	EntryContent.Archives=0;
	EntryContent.Directory=0;
	EntryContent.Hidden=0;
	EntryContent.ReadOnly=0;
	EntryContent.System=0;
	
    if(!SetEntryContent(pPath,EntryContent))
	{
		return FALSE;
	}

	return TRUE;
}

BOOL Hide_FAT32::Show()
{
	if(!Hide(0))
	{
		return FALSE;
	}

	return TRUE;
}

⌨️ 快捷键说明

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