📄 flparse.c
字号:
/***********************************************************************************/
/* M-Systems Confidential */
/* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2003 */
/* All Rights Reserved */
/***********************************************************************************/
/* NOTICE OF M-SYSTEMS OEM */
/* SOFTWARE LICENSE AGREEMENT */
/* */
/* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
/* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
/* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
/* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
/* E-MAIL = info@m-sys.com */
/***********************************************************************************/
/*
* $Log: V:/PVCSDB/DiskOnChip/archives/general storage/TrueFFS/src/fs/flparse.c-arc $
*
* Rev 1.4 Jan 14 2004 22:30:50 oris
* Replaced old (5.x) TrueFFS variable types
*
* Rev 1.3 Oct 20 2003 09:00:52 oris
* Changed comments and long file names compilation flag
*
* Rev 1.2 Sep 30 2003 17:58:54 oris
* Added support for long file names conversions.
*
* Rev 1.1 Jun 16 2003 01:18:34 oris
* Added TFFS_DLL_API prefix.
*
* Rev 1.0 Apr 09 2003 12:16:02 OriS
* Initial revision.
*
*/
#include "flcustom.h"
#include "flchkdef.h"
#ifdef PARSE_PATH
#include "fatlite.h"
/*-------------------------------------------------------------------------------------------
* f l A s c i i S t r i n g T o U n i c o d e
* Translates ANSI character null terminated string to Unicode string.
* Input: ioreq->irData - points to ASCII null terminated string to be translated to Unicode
* ioreq->irLength - buffer size in bytes
* Output: ioreq->irPath - buffer to receive translated Unicode string
* Return: flOK or other for fault
*------------------------------------------------------------------------------------------*/
TFFS_DLL_API FLStatus NAMING_CONVENTION flAsciiStringToUnicode( IOreq FAR2 *ioreq)
{
FLDword i;
FLWord *outBuf = (FLWord*)ioreq->irPath;
FLByte *inBuf = (FLByte*)ioreq->irData;
FLDword outBufSize = ioreq->irLength;
for (i=0;inBuf[i] != 0 && i < outBufSize;i++)
outBuf[i] = (FLWord) inBuf[i];
if (i < outBufSize)
outBuf[i] = 0;
else
return flBadLength;
return flOK;
}
/*-------------------------------------------------------------------------------------------
* f l U n i c o d e S t r i n g T o A s c i i
* Translates Unicode string to ANSI character null terminated string.
* Input: ioreq->irData - points to Unicode null terminated string to be translated to ASCII
* ioreq->irLength - buffer size in bytes
* Output: ioreq->irPath - buffer to receive translated ASCII string
* Return: flOK or other for fault
*------------------------------------------------------------------------------------------*/
TFFS_DLL_API FLStatus NAMING_CONVENTION flUnicodeStringToAscii( IOreq FAR2 *ioreq)
{
FLDword i;
FLByte *outBuf = (FLByte*)ioreq->irPath;
FLWord *inBuf = (FLWord*)ioreq->irData;
FLDword outBufSize = ioreq->irLength;
for (i=0;inBuf[i] != 0 && i < outBufSize;i++)
outBuf[i] = (FLByte) inBuf[i];
if (i < outBufSize)
outBuf[i] = 0;
else
return flBadLength;
return flOK;
}
/*----------------------------------------------------------------------*/
/* f l P a r s e P a t h */
/* */
/* Converts a DOS-like path string to a simple-path array. */
/* */
/* Note: Array length received in irPath must be greater than the */
/* number of path components in the path to convert. */
/* */
/* Parameters: */
/* ioreq->irData : address of path string to convert */
/* ioreq->irPath : address of array to receive parsed-path */
/* */
/* Returns: */
/* FLStatus : 0 on success, otherwise failed */
/*----------------------------------------------------------------------*/
TFFS_DLL_API FLStatus NAMING_CONVENTION flParsePath(IOreq FAR2 *ioreq)
{
FLSByte FAR1 *dosPath;
FLSimplePath FAR1 *sPath = (FLSimplePath FAR1 *)ioreq->irPath;
unsigned offset = 0, dots = 0, chars = 0;
FLBoolean isExt = FALSE;
for (dosPath = (FLSByte FAR1 *) ioreq->irData; ; dosPath++) {
if (*dosPath == '\\' || *dosPath == 0) {
if (offset != 0) {
while (offset < sizeof(FLSimplePath))
sPath->name[offset++] = ' ';
if (chars == 0) {
if (dots == 2)
sPath--;
}
else
sPath++;
offset = dots = chars = 0;
isExt = FALSE;
}
sPath->name[offset] = 0;
if (*dosPath == 0)
break;
}
else if (*dosPath == '.') {
dots++;
while (offset < sizeof sPath->name)
sPath->name[offset++] = ' ';
isExt = TRUE;
}
else if (offset < sizeof(FLSimplePath) &&
(isExt || offset < sizeof sPath->name)) {
chars++;
if (*dosPath == '*') {
while (offset < (isExt ? sizeof(FLSimplePath) : sizeof sPath->name))
sPath->name[offset++] = '?';
}
else if (*dosPath >= 'a' && *dosPath <= 'z')
sPath->name[offset++] = *dosPath - ('a' - 'A');
else
sPath->name[offset++] = *dosPath;
}
}
return flOK;
}
#endif /* PARSE_PATH */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -