form_FATEditor.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:30k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * form_FATEditor.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * FAT editor form source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #ifndef _FORM_MAIN_H_
- #include "form_main.h"
- #endif
- #ifndef _FORM_FATEDITOR_H_
- #include "form_FATEditor.h"
- #endif
- //#include "meta_utils.h"
- #ifndef _MAN_ACTIVE_H_
- #include "man_active.h"
- #endif
- #ifndef _FAT_EDITOR_H_
- #include "FAT_Editor.h"
- #endif
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TfrmFATEditor *frmFATEditor;
- extern TfrmMainSel *frmMainSel;
- //===========================================================================
- static void CNF_GetFATDiskInfo(void)
- {
- frmFATEditor->CNF_GetFATDiskInfo();
- }
- //---------------------------------------------------------------------------
- static void CNF_FATGetFileInfo(void)
- {
- frmFATEditor->CNF_FATGetFileInfo();
- }
- //---------------------------------------------------------------------------
- static void CNF_FATGetDirectoryInfo(void)
- {
- frmFATEditor->CNF_FATGetDirectoryInfo();
- }
- //---------------------------------------------------------------------------
- static void CNF_FAT_Read_To_File(void)
- {
- frmFATEditor->CNF_FAT_Read_To_File();
- }
- //---------------------------------------------------------------------------
- static void CNF_FAT_Write_By_File(void)
- {
- frmFATEditor->CNF_FAT_Write_By_File();
- }
- //---------------------------------------------------------------------------
- static void CNF_FAT_Delete(void)
- {
- frmFATEditor->CNF_FAT_Delete();
- }
- //===========================================================================
- __fastcall TfrmFATEditor::TfrmFATEditor(TComponent* Owner)
- : TForm(Owner)
- {
- m_bFirstFormShow = true;
- Init();
- }
- //---------------------------------------------------------------------------
- void TfrmFATEditor::Init(void)
- {
- m_bInit = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::FormShow(TObject *Sender)
- {
- if (m_bFirstFormShow)
- {
- // m_asCurrentFatPath =
- edtCurrentFATPath->Text = "C:\";
- btnGetDirectoryListClick(NULL);
- m_bFirstFormShow = false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::FormActivate(TObject *Sender)
- {
- BBCHIP_TYPE bb_chip = frmMainSel->Get_FinalBBChip();
- if( bb_chip == MT6205 || bb_chip == MT6205B )
- {
- btnGetFATDiskInfo->Visible = false;
- lblSectorPerCluster->Visible = false;
- lblFATTotalSize->Visible = false;
- lblFATFreeSpace->Visible = false;
- stSectorPerCluster->Visible = false;
- stFATTotalSize->Visible = false;
- stFATFreeSpace->Visible = false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::FormClose(TObject *Sender,
- TCloseAction &Action)
- {
- TimerFATProgressTimer->Enabled = false;
- HintTimer->Enabled = false;
- }
- //==========================================================================
- void TfrmFATEditor::CurrentPageReset(void)
- {
- btnWriteToFAT->Enabled = true;
- btnGetDirectoryList->Enabled = true;
- btnGetFileList->Enabled = true;
- btnReadFromFAT->Enabled = true;
- btnDeleteFromFAT->Enabled = true;
- btnGetFATDiskInfo->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void TfrmFATEditor::CurrentPageLock(void)
- {
- btnWriteToFAT->Enabled = false;
- btnGetDirectoryList->Enabled = false;
- btnGetFileList->Enabled = false;
- btnReadFromFAT->Enabled = false;
- btnDeleteFromFAT->Enabled = false;
- btnGetFATDiskInfo->Enabled = false;
- }
- //==========================================================================
- void __fastcall TfrmFATEditor::btnGetFATDiskInfoClick(TObject *Sender)
- {
- AnsiString as_DriveLetter;
- FAT_DiskInfo_T DiskInfo;
- clearProgressBar();
- clearAllPanel();
- getDriveLetterFromStr(edtCurrentFATPath->Text, as_DriveLetter);
- if (as_DriveLetter.AnsiCompareIC("") == 0)
- {
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Can not get valid drive letter from current FAT path";
- Application->MessageBox("Execution Failure : can not get valid drive letter from current FAT path", "FAILURE", MB_OK);
- return;
- }
- char c_drive_letter[1];
- strncpy(c_drive_letter, as_DriveLetter.c_str(), 1);
- m_cFAT_EDITOR_Obj.ConfirmCallback = ::CNF_GetFATDiskInfo;
- m_cFAT_EDITOR_Obj.Req_FAT_GetDiskInfo_Start(c_drive_letter[0]);
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Get FAT disk info progressing";
- }
- //---------------------------------------------------------------------------
- void TfrmFATEditor::CNF_GetFATDiskInfo(void)
- {
- E_METAAPP_RESULT_T state = m_cFAT_EDITOR_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- FAT_DiskInfo_T disk_info;
- m_cFAT_EDITOR_Obj.Get_FatDiskInfo(disk_info);
- stSectorPerCluster->Caption = IntToStr(disk_info.SectorsPerCluster );
- stFATTotalSize->Caption = IntToStr(disk_info.TotalSize );
- stFATFreeSpace->Caption = IntToStr(disk_info.FreeSpace );
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Get FAT disk info successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Get FAT disk info fail";
- Application->MessageBox("Execution Failure : get FAT disk info", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Get FAT disk info timeout";
- Application->MessageBox("Execution Timeout : get FAT disk info", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- {
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Get FAT disk info stop";
- }
- break;
- default:
- {
- DisplayFATErrorMsg();
- }
- break;
- }
- CurrentPageReset();
- }
- //===========================================================================
- void __fastcall TfrmFATEditor::btnGetDirectoryListClick(TObject *Sender)
- {
- AnsiString as_Drive;
- CurrentPageLock();
- clearProgressBar();
- clearAllPanel();
- //TimerFATDir->Enabled = true;
- // m_asParentFatPath = m_asCurrentFatPath;
- if (!getDriveFromStr(edtCurrentFATPath->Text, as_Drive))
- {
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Can not get valid drive from current FAT path";
- Application->MessageBox("Execution Failure : can not get valid drive from current FAT path", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- S_FAT_DIRECTORY_INFO_REQ_T sFatDirInfoReq;
- sFatDirInfoReq.as_FAT_dir_path = edtCurrentFATPath->Text;
- sFatDirInfoReq.as_FAT_dir_type = edtFileType->Text;
- m_cFAT_EDITOR_Obj.ConfirmCallback = ::CNF_FATGetDirectoryInfo;
- m_cFAT_EDITOR_Obj.Req_FAT_GetDirectoryInfo_Start(sFatDirInfoReq);
- }
- //----------------------------------------------------------
- void TfrmFATEditor::CNF_FATGetDirectoryInfo(void)
- {
- E_METAAPP_RESULT_T state = m_cFAT_EDITOR_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- S_FAT_DIRECTORY_INFO_CNF_T dir_info;
- m_cFAT_EDITOR_Obj.Get_FatDirInfo(dir_info);
- lbFATDirectory->Clear();
- vector<AnsiString>:: iterator iter;
- for (iter = dir_info.v_FATDirName.begin(); iter != dir_info.v_FATDirName.end(); iter++)
- {
- lbFATDirectory->Items->Add(*iter);
- }
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " FAT get directory info successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Get FAT directory list fail";
- Application->MessageBox("Execution Failure : get FAT directory list", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Get FAT directory list timeout";
- Application->MessageBox("Execution Timeout : get FAT directory list", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- {
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Get FAT directory list stop";
- }
- break;
- default:
- {
- DisplayFATErrorMsg();
- }
- break;
- }
- CurrentPageReset();
- }
- #if 0
- //==============================================================================
- void __fastcall TfrmFATEditor::TimerFATDirTimer(TObject *Sender)
- {
- if ( m_cFAT_EDITOR_Obj.Get_MetaResult() == META_SUCCESS )
- {
- edtCurrentFATPath->Text = m_asCurrentFatPath;
- lbFATDirectory->Clear();
- for(int i=0; i<m_cFAT_EDITOR_Obj.FAT_filepath_size; i++)
- {
- lbFATDirectory->Items->Add(m_cFAT_EDITOR_Obj.FAT_filepath[i]);
- }
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " FAT get directory info success";
- }
- else
- {
- DisplayFATErrorMsg();
- }
- }
- }
- #endif
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::btnGetFileListClick(TObject *Sender)
- {
- CurrentPageLock();
- clearProgressBar();
- clearAllPanel();
- //m_asParentFatPath = m_asCurrentFatPath;
- AnsiString as_Drive;
- if (!getDriveFromStr(edtCurrentFATPath->Text, as_Drive))
- {
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Can not get valid drive from current FAT path";
- Application->MessageBox("Execution Failure : can not get valid drive from current FAT path", "FAILURE", MB_OK );
- return;
- }
- CurrentPageLock();
- S_FAT_FILE_INFO_REQ_T sFatFileInfoReq;
- sFatFileInfoReq.as_FAT_file_path = edtCurrentFATPath->Text;
- sFatFileInfoReq.as_FAT_file_type = edtFileType->Text;
- if (m_rbRecursive->Checked)
- {
- sFatFileInfoReq.e_FAT_find_mode = FAT_FIND_FILE_RECURSIVE;
- }
- else
- {
- sFatFileInfoReq.e_FAT_find_mode = FAT_FIND_FILE;
- }
- // TimerFATFile->Enabled = true;
- m_cFAT_EDITOR_Obj.ConfirmCallback = ::CNF_FATGetFileInfo;
- m_cFAT_EDITOR_Obj.Req_FAT_GetFileInfo_Start(sFatFileInfoReq);
- }
- //---------------------------------------------------------------------------
- void TfrmFATEditor::CNF_FATGetFileInfo(void)
- {
- E_METAAPP_RESULT_T state = m_cFAT_EDITOR_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- S_FAT_FILE_INFO_CNF_T file_info;
- m_cFAT_EDITOR_Obj.Get_FatFileInfo(file_info);
- lbFATFile->Clear();
- vector<AnsiString>:: iterator iter;
- for (iter = file_info.v_FATFileName.begin(); iter != file_info.v_FATFileName.end(); iter++)
- {
- lbFATFile->Items->Add(*iter);
- }
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " FAT get file list successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Get FAT file list fail";
- Application->MessageBox("Execution Failure : get FAT file list", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Get FAT file list timeout";
- Application->MessageBox("Execution Timeout : get FAT file list", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- {
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Get FAT file list stop";
- }
- break;
- default:
- {
- DisplayFATErrorMsg();
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::btnReadFromFATClick(TObject *Sender)
- {
- //char str[512];
- //bool ok;
- // int i;
- if (lbFATFile->ItemIndex < 0)
- {
- ShowMessage(" You have to select a FAT file to read ");
- return;
- }
- //sbFAT->Panels->Items[STATUS_BAR_INDEX_FILENAME]->Text = " " + lbFATFile->Items->Strings[lbFATFile->ItemIndex];
- //getFilenameFromStr(lbFATFile->Items->Strings[lbFATFile->ItemIndex].c_str(), as_local_filename);
- //SaveDialog->FileName = as_local_filename;
- //ok = SaveDialog->Execute();
- //if( !ok ) return;
- //strcpy(local_filepath, SaveDialog->FileName.c_str() );
- //strcpy(FAT_filename, lbFATFile->Items->Strings[lbFATFile->ItemIndex].c_str());
- // FAT read
- AnsiString as_last_local_filepath;
- S_FAT_READ_T fat_read;
- fat_read.as_LocalFilePath = lbLocalDir->Directory;
- as_last_local_filepath = fat_read.as_LocalFilePath.SubString(fat_read.as_LocalFilePath.Length(), 1);
- if (as_last_local_filepath.AnsiCompare("\") != 0)
- {
- fat_read.as_LocalFilePath += "\";
- }
- for (int i=0; i<lbFATFile->Count; i++)
- {
- if (lbFATFile->Selected[i])
- {
- fat_read.v_FATFileName.push_back(lbFATFile->Items->Strings[i]);
- }
- }
- CurrentPageLock();
- clearProgressBar();
- clearAllPanel();
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Read file from FAT progressing";
- TimerFATProgressTimer->Enabled = true;
- m_cFAT_EDITOR_Obj.ConfirmCallback = ::CNF_FAT_Read_To_File;
- m_cFAT_EDITOR_Obj.Req_FAT_Read_To_File_Start(fat_read);
- }
- //-------------------------------------------------------------------------
- void TfrmFATEditor::CNF_FAT_Read_To_File(void)
- {
- TimerFATProgressTimer->Enabled = false;
- E_METAAPP_RESULT_T state = m_cFAT_EDITOR_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- OnTimerFATProgressTmer(NULL);
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Read file from FAT successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Read file from FAT fail";
- Application->MessageBox("Execution Failure : read file from FAT", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Read file from FAT timeout";
- Application->MessageBox("Execution Timeout : read file from FAT", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- {
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Read file from FAT stop";
- }
- break;
- default:
- {
- DisplayFATErrorMsg();
- }
- break;
- }
- CurrentPageReset();
- }
- //==============================================================================
- void __fastcall TfrmFATEditor::btnWriteToFATClick(TObject *Sender)
- {
- if (lbLocalFile->ItemIndex < 0)
- {
- ShowMessage(" You have to select a local file to write ");
- return;
- }
- AnsiString as_CurrentFatPath;
- //AnsiString as_FAT_filepath;
- //AnsiString as_FAT_filename;
- AnsiString as_local_filepath;
- AnsiString as_last_local_filepath;
- AnsiString as_last_FAT_filepath;
- int current_local_filepath_length, current_FAT_path_length;
- char *last_FAT_path_character;
- S_FAT_WRITE_T fat_write;
- clearProgressBar();
- clearAllPanel();
- CurrentPageLock();
- // FAT write
- as_local_filepath = lbLocalDir->Directory;
- current_local_filepath_length = as_local_filepath.Length();
- as_last_local_filepath = as_local_filepath.SubString(current_local_filepath_length, 1);
- if (as_last_local_filepath.AnsiCompare("\") != 0)
- {
- as_local_filepath = as_local_filepath + "\";
- }
- fat_write.as_LocalFilePath = as_local_filepath;
- for (int i=0; i<lbLocalFile->Count; i++)
- {
- if (lbLocalFile->Selected[i])
- {
- fat_write.v_LocalFileName.push_back(lbLocalFile->Items->Strings[i]);
- }
- }
- as_last_FAT_filepath = (edtCurrentFATPath->Text.SubString(current_FAT_path_length, 1));
- if (as_last_FAT_filepath.AnsiCompare("\") != 0)
- {
- as_CurrentFatPath = edtCurrentFATPath->Text + "\";
- }
- fat_write.as_FATFilePath = as_CurrentFatPath;
- // FAT info
- S_FAT_FILE_INFO_REQ_T sFatFileInfoReq;
- sFatFileInfoReq.as_FAT_file_path = edtCurrentFATPath->Text;
- sFatFileInfoReq.as_FAT_file_type = edtFileType->Text;
- if (m_rbRecursive->Checked)
- {
- sFatFileInfoReq.e_FAT_find_mode = FAT_FIND_FILE_RECURSIVE;
- }
- else
- {
- sFatFileInfoReq.e_FAT_find_mode = FAT_FIND_FILE;
- }
- #if 0
- //as_FAT_filename = as_CurrentFatPath + lbLocalFile->Items->Strings[lbLocalFile->ItemIndex];
- strcpy(FAT_filename, as_FAT_filename.c_str());
- //strcpy(local_filepath, lbLocalDir->Directory.c_str());
- // strcat(local_filepath, "\");
- // strcpy( local_filepath, as_local_filepath.c_str());
- // strcat(local_filepath, lbLocalFile->Items->Strings[lbLocalFile->ItemIndex].c_str() );
- // strcpy(FAT_filepath, m_asCurrentFatPath.c_str());
- // as_filetype = setFileTypeFromEditor();
- #endif
- TimerFATProgressTimer->Enabled = true;
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Write file to FAT progressing";
- m_cFAT_EDITOR_Obj.ConfirmCallback = ::CNF_FAT_Write_By_File;
- m_cFAT_EDITOR_Obj.Req_FAT_Write_By_File_Start(fat_write, sFatFileInfoReq);
- // m_cFAT_EDITOR_Obj.Req_FAT_Write_By_File_Start(FAT_filename, local_filepath, FAT_filepath, as_filetype.c_str());
- }
- //---------------------------------------------------------------------------
- void TfrmFATEditor::CNF_FAT_Write_By_File(void)
- {
- TimerFATProgressTimer->Enabled = false;
- E_METAAPP_RESULT_T state = m_cFAT_EDITOR_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- OnTimerFATProgressTmer(NULL);
- S_FAT_FILE_INFO_CNF_T file_info;
- m_cFAT_EDITOR_Obj.Get_FatFileInfo(file_info);
- lbFATFile->Clear();
- vector<AnsiString>:: iterator iter;
- for (iter = file_info.v_FATFileName.begin(); iter != file_info.v_FATFileName.end(); iter++)
- {
- lbFATFile->Items->Add(*iter);
- }
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Write file to FAT successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Write file to FAT fail";
- Application->MessageBox("Execution Failure : write file to FAT", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Write file to FAT timeout";
- Application->MessageBox("Execution Timeout : write file to FAT", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- {
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Write file to FAT stop";
- }
- break;
- default:
- {
- DisplayFATErrorMsg();
- }
- break;
- }
- CurrentPageReset();
- #if 0
- if(m_cFAT_EDITOR_Obj.Get_IsRunning() == false)
- {
- EnableAllButton();
- TimerFATProgressTimer->Enabled = false;
- if ( m_cFAT_EDITOR_Obj.Get_MetaResult() == META_SUCCESS)
- {
- pbFAT->Position = m_cFAT_EDITOR_Obj.Percent;
- sbFAT->Panels->Items[STATUS_BAR_INDEX_SENT_AND_TOTAL]->Text = " " + IntToStr(m_cFAT_EDITOR_Obj.SentBytes)+ " / " + IntToStr(m_cFAT_EDITOR_Obj.TotalBytes) + " bytes";
- sbFAT->Panels->Items[STATUS_BAR_INDEX_PERCENT]->Text = " " + IntToStr(m_cFAT_EDITOR_Obj.Percent) + "%";
- lbFATFile->Clear();
- for(int i=0; i<m_cFAT_EDITOR_Obj.FAT_filepath_size; i++)
- {
- lbFATFile->Items->Add(m_cFAT_EDITOR_Obj.FAT_filepath[i]);
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Write file to FAT successfully";
- }
- }
- else
- {
- DisplayFATErrorMsg( m_cFAT_EDITOR_Obj.Get_MetaResult());
- }
- }
- else
- {
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::btnDeleteFromFATClick(TObject *Sender)
- {
- //char hint[] = "Delete FAT file progressing";
- if (lbFATFile->ItemIndex < 0)
- {
- ShowMessage(" You have to select a FAT file to delete ");
- return;
- }
- //ShowHintLabel( lbFATDirectory, hint);
- CurrentPageLock();
- clearProgressBar();
- clearAllPanel();
- // FAT delete
- S_FAT_DELETE_T fat_delete;
- for (int i=0; i<lbFATFile->Count; i++)
- {
- if (lbFATFile->Selected[i])
- {
- fat_delete.v_FATFileName.push_back(lbFATFile->Items->Strings[i]);
- }
- }
- // FAT info
- S_FAT_FILE_INFO_REQ_T sFatFileInfoReq;
- sFatFileInfoReq.as_FAT_file_path = edtCurrentFATPath->Text;
- sFatFileInfoReq.as_FAT_file_type = edtFileType->Text;
- if (m_rbRecursive->Checked)
- {
- sFatFileInfoReq.e_FAT_find_mode = FAT_FIND_FILE_RECURSIVE;
- }
- else
- {
- sFatFileInfoReq.e_FAT_find_mode = FAT_FIND_FILE;
- }
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Delete FAT file progressing";
- TimerFATProgressTimer->Enabled = true;
- m_cFAT_EDITOR_Obj.ConfirmCallback = ::CNF_FAT_Delete;
- m_cFAT_EDITOR_Obj.Req_FAT_Delete_Start(fat_delete, sFatFileInfoReq);
- }
- //---------------------------------------------------------------------------
- void TfrmFATEditor::CNF_FAT_Delete(void)
- {
- TimerFATProgressTimer->Enabled = false;
- E_METAAPP_RESULT_T state = m_cFAT_EDITOR_Obj.Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- OnTimerFATProgressTmer(NULL);
- S_FAT_FILE_INFO_CNF_T file_info;
- m_cFAT_EDITOR_Obj.Get_FatFileInfo(file_info);
- lbFATFile->Clear();
- vector<AnsiString>:: iterator iter;
- for (iter = file_info.v_FATFileName.begin(); iter != file_info.v_FATFileName.end(); iter++)
- {
- lbFATFile->Items->Add(*iter);
- }
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Delete FAT file successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = " Delete FAT file fail";
- Application->MessageBox("Execution Failure : delete FAT file ", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- DisplayFATErrorMsg();
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Delete FAT file timeout";
- Application->MessageBox("Execution Timeout : delete FAT file ", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- {
- sbFAT->Panels->Items[0]->Text = (AnsiString) " Delete FAT file stop";
- }
- break;
- default:
- {
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::OnTimerFATProgressTmer(TObject *Sender)
- {
- S_FAT_PROGRESS_T progress;
- m_cFAT_EDITOR_Obj.Get_Progress(progress);
- pbFAT->Position = progress.percent;
- sbFAT->Panels->Items[STATUS_BAR_INDEX_FILENAME]->Text = " " + progress.as_file_name;
- sbFAT->Panels->Items[STATUS_BAR_INDEX_SENT_AND_TOTAL]->Text = " " + IntToStr(progress.sent_bytes)+ " / " + IntToStr(progress.total_bytes) + " bytes";
- sbFAT->Panels->Items[STATUS_BAR_INDEX_PERCENT]->Text = " " + IntToStr(progress.percent) + "%";
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::cbDriveChange(TObject *Sender)
- {
- lbLocalDir->Drive = cbDrive->Drive;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::lbLocalDirChange(TObject *Sender)
- {
- lbLocalFile->Directory = lbLocalDir->Directory;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::cbLocalFiletypeChange(TObject *Sender)
- {
- lbLocalFile->Mask = cbLocalFiletype->Mask;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFATEditor::lbFATDirectoryClick(TObject *Sender)
- {
- edtCurrentFATPath->Text = lbFATDirectory->Items->Strings[lbFATDirectory->ItemIndex];
- }
- //==============================================================================
- void TfrmFATEditor::clearProgressBar( void )
- {
- pbFAT->Position = 0;
- }
- //---------------------------------------------------------------------------
- void TfrmFATEditor::clearAllPanel( void )
- {
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = (AnsiString) "";
- sbFAT->Panels->Items[STATUS_BAR_INDEX_FILENAME]->Text = (AnsiString) "";
- sbFAT->Panels->Items[STATUS_BAR_INDEX_SENT_AND_TOTAL]->Text = (AnsiString) "";
- sbFAT->Panels->Items[STATUS_BAR_INDEX_PERCENT]->Text = (AnsiString) "";
- }
- //==============================================================================
- void TfrmFATEditor::ShowHintLabel( TControl *sender, char* hint )
- {
- TPoint pt0 = this->ClientOrigin;
- TPoint pt1 = sender->ClientOrigin;
- lblHint->Left = (pt1.x-pt0.x)+35;
- lblHint->Top = (pt1.y-pt0.y)+sender->Height-23;
- lblHint->Caption = (AnsiString) hint;
- lblHint->Visible = true;
- HintTimer->Enabled = true;
- }
- //==============================================================================
- void TfrmFATEditor::DisplayFATErrorMsg(void)
- {
- AnsiString asErrMsg;
- lbFATFile->Clear();
- m_cFAT_EDITOR_Obj.Get_ErrorString(asErrMsg);
- sbFAT->Panels->Items[STATUS_BAR_INDEX_STATUS]->Text = asErrMsg;
- asErrMsg = "Execution Result : " + asErrMsg;
- Application->MessageBox(asErrMsg.c_str(), "RESULT", MB_OK);
- }