FileSystemSrc.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:33k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * 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:
- * ---------
- * FileSystemSrc.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- *
- *
- * Author:
- * -------
- *
- *
- *==============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *==============================================================================
- *******************************************************************************/
- /**
- * Copyright Notice
- * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
- * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
- * (It is illegal to remove this copyright notice from this software or any
- * portion of it)
- */
- /**************************************************************
- FILENAME : FileSystemSrc.h
- PURPOSE : Source File for the File System
- REMARKS : nil
- AUTHOR : Yogesh
- DATE : August-01-2003
- **************************************************************/
- #include "FileSystemDef.h"
- #include "Ucs2prot.h"
- #include "MMI_features.h"
- #include "fs_type.h"
- #include "fs_func.h"
- #include "fs_errcode.h"
- #include "drm_gprot.h"
- S32 gnCurrBuffIndex = 0;
- S32 gnFileBytesRead = 0;
- U8 gFileBuffer[MAX_BUFF_SIZE];
- U8 gbIsCurrentFileEnd = FALSE;
- S32 gCurrentFileOffset = 0;
- /* Leo add for DLT */
- /*****************************************************************************
- * FUNCTION
- * Searchfile
- * DESCRIPTION
- *
- * PARAMETERS
- * file_handle [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 Searchfile(FILE_HANDLE file_handle)
- {
- #ifndef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (S32) FS_ParseFH(file_handle);
- #else /* MMI_ON_WIN32 */
- return 1;
- #endif /* MMI_ON_WIN32 */
- }
- /* Leo end */
- /*****************************************************************************
- * FUNCTION
- * pfOpenError
- * DESCRIPTION
- *
- * PARAMETERS
- * err [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 pfOpenError(FILE_HANDLE err)
- {
- #ifndef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (err < FS_NO_ERROR)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- #else /* MMI_ON_WIN32 */
- if (err < FS_NO_ERROR)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * pfError
- * DESCRIPTION
- *
- * PARAMETERS
- * err [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 pfError(S32 err)
- {
- #ifndef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (err < FS_NO_ERROR)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- #else /* MMI_ON_WIN32 */
- if (err < FS_NO_ERROR)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * GetFSFileSize
- * DESCRIPTION
- *
- * PARAMETERS
- * handle [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 GetFSFileSize(FILE_HANDLE handle)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 nfile_size;
- #ifdef MMI_ON_WIN32
- int retval;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- retval = FS_GetFileSize(handle, &nfile_size);
- if (retval == FS_NO_ERROR)
- {
- return nfile_size;
- }
- else
- {
- return 0;
- }
- #else /* MMI_ON_WIN32 */
- FS_GetFileSize(handle, (U32*) & nfile_size);
- return nfile_size;
- #endif
- }
- /*****************************************************************************
- * FUNCTION
- * StartFileRead
- * DESCRIPTION
- *
- * PARAMETERS
- * handle [IN]
- * nIndex [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 StartFileRead(FILE_HANDLE handle, U32 nIndex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 nError;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gnCurrBuffIndex = 0;
- nError = pfread(gFileBuffer, 1, MAX_BUFF_SIZE, handle, &gnFileBytesRead);
- gbIsCurrentFileEnd = FALSE;
- gCurrentFileOffset = gnFileBytesRead - 1;
- if (pfError(nError) || gnFileBytesRead < MAX_BUFF_SIZE)
- {
- gbIsCurrentFileEnd = TRUE;
- return EOF;
- }
- return 0;
- }
- /*****************************************************************************
- * FUNCTION
- * pfgetc
- * DESCRIPTION
- *
- * PARAMETERS
- * handle [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 pfgetc(FILE_HANDLE handle)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 nRead = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gnCurrBuffIndex - gnFileBytesRead >= 0)
- {
- nRead = pfread(gFileBuffer, 1, MAX_BUFF_SIZE, handle, &gnFileBytesRead);
- gCurrentFileOffset += gnFileBytesRead;
- gnCurrBuffIndex = 0;
- /* MTK modified, Max: to prevent endless file reading 1201 */
- if (pfError(nRead) || gnFileBytesRead == 0)
- {
- gbIsCurrentFileEnd = TRUE;
- return EOF;
- }
- /* MTK end */
- }
- return (S32) gFileBuffer[gnCurrBuffIndex++];
- }
- /*****************************************************************************
- * FUNCTION
- * pCacheFileRead
- * DESCRIPTION
- *
- * PARAMETERS
- * handle [IN]
- * nBufferSize [IN]
- * pnRead [?]
- * pBuffer [?]
- * RETURNS
- *
- *****************************************************************************/
- S32 pCacheFileRead(FILE_HANDLE handle, S32 nBufferSize, S32 *pnRead, U8 *pBuffer)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 nRead = 0;
- S32 nDataAvailable;
- S32 nBytesCopied = 0;
- S32 nReqdBytes = nBufferSize;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *pnRead = 0; /* Max : can be removed later */
- while (nBytesCopied < nBufferSize)
- {
- nDataAvailable = gnFileBytesRead - gnCurrBuffIndex;
- if (nDataAvailable >= nReqdBytes)
- {
- memcpy(
- (void*)(((S8*) pBuffer) + nBytesCopied),
- (void*)(((S8*) gFileBuffer) + gnCurrBuffIndex),
- nReqdBytes);
- gnCurrBuffIndex += nReqdBytes;
- *pnRead += nReqdBytes; /**pnRead = nReqdBytes; *//* Max : can be removed later */
- #ifndef MMI_ON_WIN32
- return FS_NO_ERROR;
- #else
- return nReqdBytes;
- #endif
- }
- else
- {
- memcpy((((S8*) pBuffer) + nBytesCopied), (void*)(((S8*) gFileBuffer) + gnCurrBuffIndex), nDataAvailable);
- nBytesCopied += nDataAvailable;
- /* nRead = pfread(gFileBuffer,1,MAX_BUFF_SIZE,handle,&gnFileBytesRead); */
- gCurrentFileOffset += gnFileBytesRead;
- (*pnRead) += nDataAvailable; /* nBytesCopied; *//* Max : can be removed later */
- gnCurrBuffIndex = 0;
- nReqdBytes -= nDataAvailable; /* nBytesCopied; */
- if (pfError(nRead) || gnFileBytesRead == 0)
- {
- gbIsCurrentFileEnd = TRUE;
- #ifndef MMI_ON_WIN32
- return FS_NO_ERROR;
- #else
- return nReqdBytes;
- #endif
- }
- }
- }
- #ifndef MMI_ON_WIN32
- return FS_NO_ERROR;
- #else
- return nReqdBytes;
- #endif
- }
- /*****************************************************************************
- * FUNCTION
- * IsEndOfCurrentFile
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- pBOOL IsEndOfCurrentFile()
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gnCurrBuffIndex - gnFileBytesRead >= 0)
- if (gbIsCurrentFileEnd)
- {
- return TRUE;
- }
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * pCopyFile
- * DESCRIPTION
- *
- * PARAMETERS
- * pSourceFile [IN]
- * pDestFile [IN]
- * bFailIfExists [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 pCopyFile(PU8 pSourceFile, PU8 pDestFile, pBOOL bFailIfExists)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 result = FS_NO_ERROR;
- U8 UI_temp_buffer[512];
- FILE_HANDLE fsourcefile;
- FILE_HANDLE fdestfile;
- S32 nRead;
- S32 nBytesRead = 0;
- S32 nSize = sizeof(UI_temp_buffer);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- fsourcefile = pfopen(pSourceFile, PFS_READ_BINARY);
- if (fsourcefile > 0)
- {
- if (bFailIfExists)
- {
- fdestfile = pfopen(pDestFile, PFS_READ);
- if (fdestfile)
- { /* Destination file already exists. Exit */
- pfclose(fsourcefile);
- pfclose(fdestfile);
- return FS_FILE_EXISTS;
- }
- pfclose(fdestfile);
- }
- fdestfile = pfopen(pDestFile, PFS_WRITE);
- if (fdestfile > 0)
- {
- do
- {
- nRead = pfread(UI_temp_buffer, 1, nSize, fsourcefile, &nBytesRead);
- result = pfwrite(UI_temp_buffer, 1, nBytesRead, fdestfile, &nRead);
- } while (nBytesRead >= nSize && result == FS_NO_ERROR);
- pfclose(fdestfile);
- }
- else
- {
- result = (S32) fdestfile;
- }
- pfclose(fsourcefile);
- return result;
- }
- else
- {
- return (S32) fsourcefile;
- }
- }
- #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
- /*****************************************************************************
- * FUNCTION
- * pCopyFileFromOffset
- * DESCRIPTION
- *
- * PARAMETERS
- * fSourceFile [IN]
- * pDestFile [IN]
- * offset [IN]
- * size [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 pCopyFileFromOffset(FILE_HANDLE fSourceFile, PU8 pDestFile, U32 offset, U32 size)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 result = FS_NO_ERROR;
- U32 fp;
- U8 temp_buffer[512];
- FILE_HANDLE fDestFile;
- U32 nBytesWritten = 0;
- U32 nBytesRead = 0;
- U32 nSize = sizeof(temp_buffer);
- U16 iter = (size / 512);
- U16 lastIter = (size % 512);
- U16 i = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- FS_GetFilePosition(fSourceFile, &fp);
- fDestFile = FS_Open((U16*) pDestFile, FS_CREATE | FS_READ_WRITE);
- if (fDestFile > 0)
- {
- DRM_seek_file(fSourceFile, offset, FS_FILE_BEGIN);
- do
- {
- DRM_read_file(fSourceFile, temp_buffer, nSize, &nBytesRead);
- result = FS_Write(fDestFile, temp_buffer, nBytesRead, &nBytesWritten);
- ++i;
- /* } while(nBytesRead>=nSize && result == FS_NO_ERROR); */
- } while (i < iter && result == FS_NO_ERROR);
- DRM_read_file(fSourceFile, temp_buffer, lastIter, &nBytesRead);
- result = FS_Write(fDestFile, temp_buffer, nBytesRead, &nBytesWritten);
- FS_Close(fDestFile);
- /* if there is an error in writing or reading the audio file then tem file must be deleted */
- if (result != FS_NO_ERROR)
- {
- FS_Delete((U16*) pDestFile);
- }
- }
- else
- {
- result = (S32) fDestFile;
- }
- DRM_seek_file(fSourceFile, fp, FS_FILE_BEGIN);
- return result;
- }
- #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */
- #ifdef MMI_ON_WIN32
- /*****************************************************************************
- * FUNCTION
- * OpenFileFS
- * DESCRIPTION
- *
- * PARAMETERS
- * pFileName [?]
- * pType [?]
- * RETURNS
- *
- *****************************************************************************/
- FILE_HANDLE OpenFileFS(U8 *pFileName, U8 *pType)
- {
- #ifdef __UCS2_ENCODING
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *filename;
- #else /* __UCS2_ENCODING */
- U8 filename[MAX_FILE_NAME];
- #endif /* __UCS2_ENCODING */
- FILE_HANDLE f = -1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __UCS2_ENCODING
- filename = pFileName;
- #else /* __UCS2_ENCODING */
- AnsiiToUnicodeString(filename, pFileName);
- #endif /* __UCS2_ENCODING */
- if (strstr(pType, "r+"))
- {
- f = FS_Open((WCHAR*) filename, FS_READ_WRITE);
- }
- else if (strstr(pType, "r"))
- {
- f = FS_Open((WCHAR*) filename, FS_READ_ONLY);
- }
- else if (strstr(pType, "w"))
- {
- /* "w" and "w+" have the same effect */
- f = FS_Open((WCHAR*) filename, FS_READ_WRITE | FS_CREATE_ALWAYS);
- }
- else if (strstr(pType, "a"))
- {
- /* "a" and "a+" have the same effect */
- f = FS_Open((WCHAR*) filename, FS_READ_WRITE | FS_CREATE_ALWAYS);
- if (f > FS_NO_ERROR)
- {
- FS_Seek(f, 0, FS_FILE_END);
- }
- }
- /*
- * NoteXXX: Originally FILE_HANDLE is defined as (FILE *)
- * and OpenFSFile() will use fopen to open a file.
- * If fail, the return value is NULL.
- * But zero value means success for our FS_HANDLE.
- * For backward compatibility, we need to do a little
- * conversion.
- *
- */
- if (f < FS_NO_ERROR)
- {
- return 0;
- }
- else
- {
- return f;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * fdelete
- * DESCRIPTION
- *
- * PARAMETERS
- * fFile [?]
- * RETURNS
- *
- *****************************************************************************/
- S32 fdelete(U8 *fFile)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- int retval;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- retval = FS_Delete((WCHAR*) fFile);
- if (retval == FS_NO_ERROR)
- /* succeed */
- {
- return 0;
- }
- else
- /* fail */
- {
- return 1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * frename
- * DESCRIPTION
- *
- * PARAMETERS
- * sFile [?]
- * dFile [?]
- * RETURNS
- *
- *****************************************************************************/
- S32 frename(U8 *sFile, U8 *dFile)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- int retval;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- retval = FS_Rename((WCHAR*) sFile, (WCHAR*) dFile);
- if (retval == FS_NO_ERROR)
- /* succeed */
- {
- return 1;
- }
- else
- /* fail */
- {
- return 0;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * pFindFirstEx
- * DESCRIPTION
- *
- * PARAMETERS
- * x1 [IN]
- * x2 [IN]
- * x3 [IN]
- * x4 [?]
- * x5 [IN]
- * x6 [IN]
- * RETURNS
- *
- *****************************************************************************/
- FILE_HANDLE pFindFirstEx(const PS8 x1, U8 x2, U8 x3, void *x4, PS8 x5, U32 x6)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return 0;
- }
- /*****************************************************************************
- * FUNCTION
- * pFindNextEx
- * DESCRIPTION
- *
- * PARAMETERS
- * x1 [IN]
- * x2 [?]
- * x3 [IN]
- * x4 [IN]
- * RETURNS
- *
- *****************************************************************************/
- U8 pFindNextEx(FILE_HANDLE x1, void *x2, PS8 x3, U32 x4)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return -1;
- }
- /*****************************************************************************
- * FUNCTION
- * CloseFileFS
- * DESCRIPTION
- *
- * PARAMETERS
- * f [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void CloseFileFS(FILE_HANDLE f)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- FS_Close(f);
- }
- /*****************************************************************************
- * FUNCTION
- * WriteFileFS
- * DESCRIPTION
- *
- * PARAMETERS
- * buffer [IN]
- * size [IN]
- * count [IN]
- * f [IN]
- * RETURNS
- *
- *****************************************************************************/
- size_t WriteFileFS(const void *buffer, size_t size, size_t count, FILE_HANDLE f)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 write;
- int retval;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- retval = FS_Write(f, (void*)buffer, size * count, &write);
- if (retval == FS_NO_ERROR)
- /* succeed */
- {
- return write;
- }
- else
- /* fail */
- {
- return 0;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * ReadFileFS
- * DESCRIPTION
- *
- * PARAMETERS
- * buffer [?]
- * size [IN]
- * count [IN]
- * f [IN]
- * read [?]
- * RETURNS
- *
- *****************************************************************************/
- size_t ReadFileFS(void *buffer, size_t size, size_t count, FILE_HANDLE f, size_t *read)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 dummyread;
- int retval;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (read == NULL)
- {
- read = &dummyread;
- }
- retval = FS_Read(f, buffer, size * count, read);
- if (retval != FS_NO_ERROR)
- /* fail */
- {
- *read = EOF;
- }
- return *read;
- }
- /*****************************************************************************
- * FUNCTION
- * CreateDir
- * DESCRIPTION
- *
- * PARAMETERS
- * pPath [?]
- * RETURNS
- *
- *****************************************************************************/
- S32 CreateDir(U8 *pPath)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 nLen = 0;
- S32 nCount = 0;
- S32 nRetVal;
- U16 nFirstTime = TRUE;
- U8 aTempPath[150];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nLen = UCS2Strlen((PS8) pPath);
- nLen *= ENCODING_LENGTH;
- while (nCount < nLen)
- {
- if (pPath[nCount] == '\' && pPath[nCount + 1] == ' ')
- {
- if (!nFirstTime)
- {
- aTempPath[nCount] = ' ';
- aTempPath[nCount + 1] = ' ';
- nRetVal = FS_CreateDir((U16*) aTempPath);
- //if(nRetVal<FS_NO_ERROR) // vikram...08/11/2003
- // return nRetVal;
- }
- else
- {
- nFirstTime = FALSE;
- }
- }
- aTempPath[nCount] = pPath[nCount];
- aTempPath[nCount + 1] = pPath[nCount + 1];
- nCount += 2;
- }
- aTempPath[nCount] = ' ';
- aTempPath[nCount + 1] = ' ';
- nRetVal = FS_CreateDir((U16*) aTempPath);
- return nRetVal;
- }
- /*****************************************************************************
- * FUNCTION
- * OpenCache
- * DESCRIPTION
- *
- * PARAMETERS
- * pFileName [?]
- * nType [?]
- * RETURNS
- *
- *****************************************************************************/
- FILE_HANDLE OpenCache(U8 *pFileName, U8 *nType)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- file = pfopen(pFileName, nType);
- if (pfOpenError(file))
- {
- return 0;
- }
- else
- {
- StartFileRead(file, 0);
- }
- return file;
- }
- #endif /* MMI_ON_WIN32 */
- #ifndef MMI_ON_WIN32
- /*****************************************************************************
- * FUNCTION
- * CreateDir
- * DESCRIPTION
- *
- * PARAMETERS
- * pPath [?]
- * RETURNS
- *
- *****************************************************************************/
- S32 CreateDir(U8 *pPath)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 nLen = 0;
- S32 nCount = 0;
- S32 nRetVal;
- U16 nFirstTime = TRUE;
- U8 aTempPath[150];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nLen = UCS2Strlen((PS8) pPath);
- nLen *= ENCODING_LENGTH;
- while (nCount < nLen)
- {
- if (pPath[nCount] == '\' && pPath[nCount + 1] == ' ')
- {
- if (!nFirstTime)
- {
- aTempPath[nCount] = ' ';
- aTempPath[nCount + 1] = ' ';
- nRetVal = FS_CreateDir((U16*) aTempPath);
- //if(nRetVal<FS_NO_ERROR) // vikram...08/11/2003
- // return nRetVal;
- }
- else
- {
- nFirstTime = FALSE;
- }
- }
- aTempPath[nCount] = pPath[nCount];
- aTempPath[nCount + 1] = pPath[nCount + 1];
- nCount += 2;
- }
- aTempPath[nCount] = ' ';
- aTempPath[nCount + 1] = ' ';
- nRetVal = FS_CreateDir((U16*) aTempPath);
- return nRetVal;
- }
- /*****************************************************************************
- * FUNCTION
- * OpenCache
- * DESCRIPTION
- *
- * PARAMETERS
- * pFileName [?]
- * nType [IN]
- * RETURNS
- *
- *****************************************************************************/
- FILE_HANDLE OpenCache(U8 *pFileName, S32 nType)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- file = pfopen(pFileName, nType);
- if (pfOpenError(file))
- {
- return NULL;
- }
- else
- {
- StartFileRead(file, 0);
- }
- return file;
- }
- #endif /* MMI_ON_WIN32 */