imgtools/romtools/rofsbuild/fsnode.cpp
author Zheng Shen <zheng.shen@nokia.com>
Thu, 09 Sep 2010 19:09:10 +0800
changeset 633 a4eca1f021ac
parent 617 3a747a240983
child 647 53d1ab72f5bc
permissions -rw-r--r--
ROMTools-13.1.0.2 Bug 3415 - SBS failing to build open C libraries
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     1
/*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     3
* All rights reserved.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     4
* This component and the accompanying materials are made available
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     6
* which accompanies this distribution, and is available
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     8
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     9
* Initial Contributors:
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    11
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    12
* Contributors:
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    13
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    14
* Description: 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    15
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    16
*/
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    17
#include "fsnode.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    18
#include "fatdefines.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    19
#include "utf16string.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    20
#include <stdio.h> 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    21
#include <iostream>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    22
#include <iomanip>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    23
#include <stdio.h> 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    24
#include <stdlib.h> 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    25
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    26
#include <ctype.h> 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    27
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    28
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    29
#ifdef __LINUX__
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    30
#include <dirent.h> 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    31
#include <sys/stat.h>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    32
#include <unistd.h>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    33
#define SPLIT_CHAR '/'
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    34
#else
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    35
#include <io.h> 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    36
#include <direct.h> //TODO: check under MinGW4 + stlport 5.2
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    37
#include <conio.h> 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    38
#define SPLIT_CHAR '\\'
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    39
#endif
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    40
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    41
using namespace std;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    42
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    43
const TUint KBytesPerEntry = 13 ;
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    44
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    45
static inline bool is_a_long_file_name_char(unsigned char ch){
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    46
	return ( ch >= ' ' && ch != '"' && ch != '*' && ch != ':' && ch != '<' \
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    47
		&& ch != '>' && ch != '?' && ch != '|' && ch != 127) ; 
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    48
	
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    49
}
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    50
//
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    51
TFSNode::TFSNode(TFSNode* aParent, const char* aFileName, TUint8 aAttrs, const char* aPCSideName)  :
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    52
iParent(aParent),iFirstChild(0),iSibling(0),iAttrs(aAttrs), iPCSideName(0), iWideName(0){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    53
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    54
  // According to the FAT specification, short name should be inited with empty string (' ' string)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    55
	memset(iShortName,0x20,11);  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    56
	iShortName[11] = 0 ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    57
	if(aFileName) {
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    58
		const unsigned char* ptr = reinterpret_cast<const unsigned char*>(aFileName);
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    59
		bool allSpaces = true ;
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    60
		while(*ptr){
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    61
			if( !is_a_long_file_name_char(*ptr))
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    62
				throw "Illegal filename or dir name! \n";		
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    63
			if(*ptr != ' ')
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    64
				allSpaces = false ;		
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    65
			ptr++ ;
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    66
		}
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    67
		if(allSpaces)
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    68
			throw "Illegal filename or dir name(all spaces)!\n";
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
    69
		iFileName = strdup(aFileName); 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    70
		GenerateBasicName() ;	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    71
	} 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    72
	if(aPCSideName) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    73
		iPCSideName = strdup(aPCSideName);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    74
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    75
	iFATEntry = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    76
	iCrtTimeTenth  = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    77
	iCrtTime.iImageTime = 0 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    78
	iCrtDate.iImageDate = 0 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    79
	iLstAccDate.iImageDate = 0  ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    80
	iWrtTime.iImageTime = 0 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    81
	iWrtDate.iImageDate = 0  ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    82
	iFileSize = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    83
	if(!iParent) return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    84
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    85
	if(!iParent->iFirstChild)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    86
	    iParent->iFirstChild = this ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    87
    else {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    88
        TFSNode* sibling = iParent->iFirstChild;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    89
        while(sibling->iSibling)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    90
            sibling = sibling->iSibling ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    91
        sibling->iSibling = this ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    92
    } 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    93
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    94
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    95
TFSNode::~TFSNode(){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    96
	if(iFirstChild)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    97
		delete iFirstChild ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    98
	if(iSibling)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    99
		delete iSibling ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   100
	if(iFileName)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   101
		free(iFileName) ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   102
	if(iWideName)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   103
		delete iWideName;
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   104
	if(iPCSideName)
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   105
		free(iPCSideName);
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   106
}
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   107
 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   108
TFSNode* TFSNode::CreateFromFolder(const char* aPath,TFSNode* aParent) { 
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   109
	 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   110
	int len = strlen(aPath);  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   111
#ifdef __LINUX__
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   112
	DIR* dir = opendir(aPath);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   113
	if(dir == NULL) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   114
		cout << aPath << " does not contain any subfolder/file.\n";     
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   115
			return aParent;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   116
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   117
	if(!aParent)
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   118
		aParent = new TFSNode(NULL,"/",ATTR_DIRECTORY);
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   119
	dirent*  entry; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   120
	struct stat statbuf ;
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   121
	char* fileName = new(nothrow) char[len + 200];
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   122
	if(!fileName) return NULL ;
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   123
	memcpy(fileName,aPath,len); 
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   124
	fileName[len] = SPLIT_CHAR;
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   125
	while ((entry = readdir(dir)) != NULL)  {
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   126
		if(strcmp(entry->d_name,".") == 0 || strcmp(entry->d_name,"..") == 0)
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   127
			continue ; 
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   128
		strcpy(&fileName[len+1],entry->d_name);             
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   129
		stat(fileName , &statbuf);         
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   130
		TFSNode* pNewItem = new TFSNode(aParent,fileName,S_ISDIR(statbuf.st_mode) ? ATTR_DIRECTORY : 0);
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   131
		pNewItem->Init(statbuf.st_ctime,statbuf.st_atime,statbuf.st_mtime,statbuf.st_size);         
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   132
		if(S_ISDIR(statbuf.st_mode)){ 
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   133
			CreateFromFolder(fileName,pNewItem);
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   134
		} 
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   135
	}	
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   136
	delete []fileName ;
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   137
	closedir(dir);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   138
#else
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   139
	struct _finddata_t data ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   140
	memset(&data, 0, sizeof(data)); 	
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   141
	char* fileName = new(nothrow) char[len + 200];
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   142
	if(!fileName) return NULL ;
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   143
	memcpy(fileName,aPath,len); 
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   144
    fileName[len] = SPLIT_CHAR;
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   145
	fileName[len+1] = '*';
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   146
	fileName[len+2] = 0;
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   147
	intptr_t hFind =  _findfirst(fileName,&data); 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   148
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   149
	if(hFind == (intptr_t)-1 ) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   150
		cout << aPath << " does not contain any subfolder/file.\n";		
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   151
		delete []fileName;
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   152
		return aParent;
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   153
	}	
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   154
	if(!aParent)
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   155
	    aParent = new TFSNode(NULL,"/",ATTR_DIRECTORY);	
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   156
	
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   157
	do {        
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   158
        if(strcmp(data.name,".") == 0 || strcmp(data.name,"..") == 0)
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   159
            continue ; 
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   160
        
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   161
        strcpy(&fileName[len+1],data.name); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   162
        TUint8 attr = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   163
        if(data.attrib & _A_SUBDIR)  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   164
            attr |= ATTR_DIRECTORY;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   165
        if(data.attrib & _A_RDONLY)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   166
            attr |= ATTR_READ_ONLY ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   167
        if(data.attrib &  _A_HIDDEN)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   168
            attr |= ATTR_HIDDEN ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   169
        if(data.attrib & _A_SYSTEM)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   170
            attr |= ATTR_SYSTEM ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   171
        if(data.attrib & _A_ARCH)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   172
            attr |= ATTR_ARCHIVE;      
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   173
        TFSNode* pNewItem = new TFSNode(aParent,data.name,attr,fileName);        
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   174
        pNewItem->Init(data.time_create,data.time_access,data.time_write,data.size);            
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   175
        if(data.attrib & _A_SUBDIR){ 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   176
            CreateFromFolder(fileName,pNewItem);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   177
        }  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   178
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   179
    } while(-1 != _findnext(hFind, &data));
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   180
	delete []fileName ;
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   181
    _findclose(hFind);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   182
#endif
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   183
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   184
	return aParent;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   185
}
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   186
 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   187
/** GenerateBasicName : Generate the short name according to long name 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   188
	* 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   189
	* algorithm :
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   190
	* 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   191
	* 1.	The UNICODE name passed to the file system is converted to upper case.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   192
	* 2.	The upper cased UNICODE name is converted to OEM.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   193
	*     if (the uppercased UNICODE glyph does not exist as an OEM glyph in the OEM code page)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   194
	*				or	(the OEM glyph is invalid in an 8.3 name)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   195
	*			{
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   196
	*				Replace the glyph to an OEM '_' (underscore) character.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   197
	*				Set a "lossy conversion" flag.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   198
	*			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   199
	* 3.	Strip all leading and embedded spaces from the long name.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   200
	* 4.	Strip all leading periods from the long name.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   201
	* 5.	While		(not at end of the long name)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   202
	*					and	(char is not a period)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   203
	*					and	(total chars copied < 8)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   204
	*			{
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   205
	*				Copy characters into primary portion of the basis name
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   206
	*			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   207
	*	6.	Insert a dot at the end of the primary components of the basis-name 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   208
	*     if the basis name has an extension after the last period in the name.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   209
	*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   210
	* 7.	Scan for the last embedded period in the long name.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   211
	*     If	(the last embedded period was found)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   212
	*     {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   213
	*     	While		(not at end of the long name) and	(total chars copied < 3)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   214
	*     	{
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   215
	*     		Copy characters into extension portion of the basis name
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   216
	*     	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   217
	*     }
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   218
  *
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   219
  */
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   220
void TFSNode::GenerateBasicName() { 
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   221
	const char* filename =  iFileName ;	 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   222
	TUint length = strlen(filename);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   223
	if(0 == length)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   224
	    return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   225
	if(0 == strcmp(filename,".")){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   226
        iShortName[0] = '.' ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   227
        return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   228
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   229
	if(0 == strcmp(filename,"..")){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   230
        iShortName[0] = '.' ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   231
        iShortName[1] = '.' ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   232
        return ;
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   233
	} 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   234
	iWideName = new UTF16String(filename,length); // The unicode string
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   235
	char base[10];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   236
	const char* ext = filename + length;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   237
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   238
	//Strip all leading periods and spaces from the long name.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   239
	while(*filename == '.' || *filename == ' ' || *filename == '\t') {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   240
		filename ++ ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   241
		length -- ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   242
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   243
	//find the extension
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   244
	while(ext > filename && *ext != '.')
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   245
		ext -- ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   246
	if(ext == filename){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   247
		ext = "" ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   248
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   249
	else {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   250
		length = ext - filename;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   251
		ext ++ ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   252
	} 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   253
	bool lossyConv = false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   254
	TUint bl = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   255
	for(TUint i = 0 ; i < length ; i++) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   256
		if(filename[i] >= 'a' && filename[i] <= 'z')
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   257
			base[bl++] = filename[i] + 'A' - 'a';
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   258
		else if(filename[i] >= 'A' && filename[i] <= 'Z')
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   259
			base[bl++] = filename[i];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   260
		else if(filename[i] == '$' || filename[i] == '%' ||
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   261
			filename[i] == '-' || filename[i] == '_' || filename[i] == '@' ||
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   262
			filename[i] == '~' || filename[i] == '`' || filename[i] == '!' ||
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   263
			filename[i] == '(' || filename[i] == ')' || filename[i] == '{' ||
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   264
			filename[i] == '}' || filename[i] == '^' || filename[i] == '#' ||
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   265
			filename[i] == '&' ||filename[i] == '\'')
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   266
			base[bl++] = filename[i];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   267
		else if(filename[i] != ' ' && filename[i] != '.'){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   268
			base[bl++] = '_';
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   269
			lossyConv = true ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   270
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   271
		if(bl > 8){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   272
			bl -- ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   273
			lossyConv = true ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   274
			break ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   275
		}		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   276
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   277
	if(lossyConv){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   278
		if(bl > 6) bl = 6 ;		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   279
		iShortName[bl] = '~';
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   280
		iShortName[bl+1] = '1';		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   281
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   282
	memcpy(iShortName,base,bl);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   283
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   284
	//Copy the extension part.	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   285
	TUint ei = 8;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   286
	for(TUint e = 0; ei < 11 && ext[e] != 0 ; e++){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   287
		if(ext[e] >= 'a' && ext[e] <= 'z')
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   288
			iShortName[ei++] = ext[e] + 'A' - 'a';
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   289
		else if(ext[e] >= 'A' && ext[e] <= 'Z')
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   290
			iShortName[ei++] = ext[e] ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   291
		else if(ext[e] == '$' || ext[e] == '%' || ext[e] == '-' || ext[e] == '_' || 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   292
			ext[e] == '@' || ext[e] == '~' || ext[e] == '`' || ext[e] == '!' || 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   293
			ext[e] == '(' || ext[e] == ')' || ext[e] == '{' || ext[e] == '}' || 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   294
			ext[e] == '^' || ext[e] == '#' || ext[e] == '&' ||ext[e] == '\'')
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   295
			iShortName[ei++] = ext[e] ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   296
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   297
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   298
	if(iParent) 
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   299
		iParent->MakeUniqueShortName(iShortName,bl); 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   300
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   301
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   302
#ifdef _DEBUG
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   303
void TFSNode::PrintTree(int nTab) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   304
	for( int i = 0 ; i < nTab ; i++ )
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   305
		cout << " " ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   306
	cout << (iFileName ? iFileName : "") << " [" << hex << setw(2) << setfill('0') << (unsigned short)iAttrs << "] \n" ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   307
	if(iFirstChild)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   308
		iFirstChild->PrintTree(nTab + 2);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   309
	if(iSibling)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   310
		iSibling->PrintTree(nTab);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   311
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   312
#endif
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   313
bool TFSNode::IsDirectory() const {
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   314
	return (0 != (iAttrs & ATTR_DIRECTORY) || ATTR_VOLUME_ID == iAttrs) ;
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   315
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   316
int TFSNode::GetWideNameLength() const {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   317
	if(!iWideName)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   318
		return 0 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   319
	return iWideName->length() ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   320
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   321
TUint TFSNode::GetSize() const {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   322
	
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   323
	if( !IsDirectory())
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   324
		return iFileSize ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   325
	TUint retVal = sizeof(TShortDirEntry) ; // the tailed entry 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   326
	if(iParent)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   327
		retVal += sizeof(TShortDirEntry) * 2 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   328
	TFSNode* child = iFirstChild ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   329
	while(child) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   330
		TUint longNameEntries =  (child->GetWideNameLength() + KBytesPerEntry) / KBytesPerEntry  ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   331
		retVal += longNameEntries * sizeof(TLongDirEntry) ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   332
		retVal += sizeof(TShortDirEntry);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   333
		child = child->iSibling ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   334
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   335
	return retVal ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   336
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   337
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   338
void TFSNode::Init(time_t aCreateTime, time_t aAccessTime, time_t aWriteTime, TUint aSize ) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   339
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   340
	struct tm* temp = localtime(&aCreateTime);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   341
	iCrtDate.iCurrentDate.Day = temp->tm_mday;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   342
	iCrtDate.iCurrentDate.Month = temp->tm_mon+1; //As per FAT spec
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   343
	iCrtDate.iCurrentDate.Year = temp->tm_year - 80;//As per FAT spec
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   344
	iCrtTime.iCurrentTime.Hour = temp->tm_hour;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   345
	iCrtTime.iCurrentTime.Minute = temp->tm_min;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   346
	iCrtTime.iCurrentTime.Seconds = temp->tm_sec / 2;//As per FAT spec
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   347
	iCrtTimeTenth = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   348
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   349
	temp = localtime(&aAccessTime);	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   350
	iLstAccDate.iCurrentDate.Day = temp->tm_mday;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   351
	iLstAccDate.iCurrentDate.Month = temp->tm_mon+1; //As per FAT spec
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   352
	iLstAccDate.iCurrentDate.Year = temp->tm_year - 80;//As per FAT spec
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   353
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   354
	temp = localtime(&aWriteTime);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   355
	iWrtDate.iCurrentDate.Day = temp->tm_mday;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   356
	iWrtDate.iCurrentDate.Month = temp->tm_mon+1; //As per FAT spec
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   357
	iWrtDate.iCurrentDate.Year = temp->tm_year - 80;//As per FAT spec
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   358
	iWrtTime.iCurrentTime.Hour = temp->tm_hour;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   359
	iWrtTime.iCurrentTime.Minute = temp->tm_min;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   360
	iWrtTime.iCurrentTime.Seconds = temp->tm_sec / 2;//As per FAT spec 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   361
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   362
	iFileSize = aSize ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   363
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   364
/** WriteDirEntries : Write FAT information for this node to a cluster buffer
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   365
	* aStartIndex : [in],the beginning index of the outputed cluster  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   366
  * aClusterData : [in,out] the cluster buffer
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   367
  * 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   368
  * notice, aClusterData is only required if node is a directory node.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   369
  * for a file node, no data will be written out.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   370
  * in this case, only corresponding cluster index information is updated.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   371
  */ 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   372
void TFSNode::WriteDirEntries(TUint aStartIndex,TUint8* aClusterData){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   373
	if(iFATEntry){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   374
		*((TUint16*)iFATEntry->DIR_FstClusHI) = (aStartIndex >> 16) ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   375
		*((TUint16*)iFATEntry->DIR_FstClusLO) = (aStartIndex & 0xFFFF) ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   376
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   377
	 
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 605
diff changeset
   378
	if(IsDirectory()) { // Directory , write dir entries ; 
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   379
		TShortDirEntry* entry = reinterpret_cast<TShortDirEntry*>(aClusterData);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   380
		if(iParent != NULL) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   381
			//Make 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   382
			GetShortEntry(entry); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   383
			//TODO: Add comments to avoid mistaken deleting.			
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   384
			memcpy(entry->DIR_Name,".            ",sizeof(entry->DIR_Name));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   385
			entry ++ ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   386
			iParent->GetShortEntry(entry);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   387
			memcpy(entry->DIR_Name,"..           ",sizeof(entry->DIR_Name));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   388
			entry ++ ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   389
		}		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   390
		TFSNode* child = iFirstChild ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   391
		while(child){			
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   392
			int items = child->GetLongEntries(reinterpret_cast<TLongDirEntry*>(entry));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   393
			entry += items ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   394
			child->GetShortEntry(entry);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   395
			child->iFATEntry = entry ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   396
			entry ++ ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   397
			child = child->iSibling ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   398
			
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   399
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   400
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   401
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   402
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   403
/** GetShortEntry : Make a short directory entry (FAT16/32 conception)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   404
  * aEntry : the entry buffer   
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   405
  */ 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   406
void TFSNode::GetShortEntry(TShortDirEntry* aEntry) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   407
  if(!aEntry) return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   408
	if(iFATEntry){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   409
		if(iFATEntry != aEntry)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   410
			memcpy(aEntry,iFATEntry,sizeof(TShortDirEntry));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   411
		return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   412
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   413
	memcpy(aEntry->DIR_Name,iShortName,sizeof(aEntry->DIR_Name)); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   414
	aEntry->DIR_Attr = iAttrs;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   415
	aEntry->DIR_NTRes = 0 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   416
	aEntry->DIR_CrtTimeTenth = 0 ;        
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   417
	memcpy(aEntry->DIR_CrtTime,&iCrtTime,sizeof(aEntry->DIR_CrtTime)); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   418
	memcpy(aEntry->DIR_CrtDate,&iCrtDate,sizeof(aEntry->DIR_CrtDate));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   419
	memcpy(aEntry->DIR_LstAccDate,&iLstAccDate,sizeof(aEntry->DIR_LstAccDate));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   420
	memset(aEntry->DIR_FstClusHI,0,sizeof(aEntry->DIR_FstClusHI));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   421
	memcpy(aEntry->DIR_WrtTime,&iWrtTime,sizeof(aEntry->DIR_WrtTime)); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   422
	memcpy(aEntry->DIR_WrtDate,&iWrtDate,sizeof(aEntry->DIR_WrtDate)); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   423
	memset(aEntry->DIR_FstClusLO,0,sizeof(aEntry->DIR_FstClusLO)); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   424
	memcpy(aEntry->DIR_FileSize,&iFileSize,sizeof(aEntry->DIR_FileSize));  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   425
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   426
TUint8 FATChkSum(const char* pFcbName) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   427
    short fcbNameLen ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   428
    TUint8 sum = 0 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   429
    for(fcbNameLen = 11 ; fcbNameLen != 0 ; fcbNameLen --) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   430
        sum = ((sum & 1) ? 0x80 : 0 ) + (sum >> 1 ) + *pFcbName++ ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   431
    }
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   432
    return sum ;        
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   433
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   434
/** GetLongEntries : Make a series of long directory entries (FAT16/32 conception)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   435
  * aEntries : the start addr of the long directory entries buffer
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   436
  *
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   437
  * return value : actual entris count.   
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   438
  */ 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   439
int TFSNode::GetLongEntries(TLongDirEntry* aEntries) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   440
  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   441
  if(!aEntries) return 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   442
	int packs = (GetWideNameLength() + KBytesPerEntry) / KBytesPerEntry  ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   443
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   444
	TUint buflen = packs * KBytesPerEntry;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   445
	TUint16* buffer = new(std::nothrow) TUint16[buflen];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   446
	if(!buffer)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   447
	return 0 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   448
	memset(buffer,0xff,(buflen << 1));    
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   449
	if(iWideName) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   450
	    memcpy(buffer,iWideName->c_str(),iWideName->bytes()); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   451
	    buffer[iWideName->length()] = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   452
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   453
	TUint8 chkSum = FATChkSum(iShortName);;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   454
    
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   455
	TUint16* ptr = buffer ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   456
	TLongDirEntry* entry = aEntries +(packs - 1);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   457
  for(int i = 1 ; i <= packs ; i++, entry--) {		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   458
		entry->LDIR_Ord = i ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   459
		entry->LDIR_Chksum = chkSum ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   460
		entry->LDIR_Attr = (TUint8)ATTR_LONG_NAME;    
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   461
		*((TUint16*)(entry->LDIR_FstClusLO)) = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   462
		entry->LDIR_Type = 0;         
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   463
		memcpy(entry->LDIR_Name1,ptr,10); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   464
		memcpy(entry->LDIR_Name2,&ptr[5],12); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   465
		memcpy(entry->LDIR_Name3,&ptr[11],4);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   466
		ptr += 13; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   467
  }
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   468
	aEntries->LDIR_Ord |= 0x40 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   469
    
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   470
	delete []buffer ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   471
	return packs ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   472
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   473
/** Make a unique name for a new child which has not been added.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   474
  * to avoid same short names under a directory
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   475
  * rShortName : [in,out] , The new short name to be checked and changed.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   476
  * baseNameLength: [in], the length of the base part of the short name 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   477
  * not including the "~n"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   478
  * for example, 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   479
  *  "ABC.LOG" => baseNameLength == 3 ("ABC")
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   480
  *  "AB~1.TXT" => baseNameLength == 2 ("AB")
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   481
  *
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   482
  *
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   483
  *The Numeric-Tail Generation Algorithm
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   484
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   485
  * If (a "lossy conversion" was not flagged)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   486
  * 		and	(the long name fits within the 8.3 naming conventions)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   487
  * 		and	(the basis-name does not collide with any existing short name)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   488
  * {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   489
  * 	The short name is only the basis-name without the numeric tail.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   490
  * }
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   491
  * else {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   492
  * 	Insert a numeric-tail "~n" to the end of the primary name such that the value of 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   493
  *		the "~n" is chosen so that the name thus formed does not collide with 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   494
  *		any existing short name and that the primary name does not exceed eight
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   495
  *		characters in length.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   496
  * }
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   497
  * The "~n" string can range from "~1" to "~999999". 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   498
  *
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   499
  */
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   500
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   501
void TFSNode::MakeUniqueShortName(char rShortName[12],TUint baseNameLength) const { 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   502
	bool dup ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   503
	char nstring[10];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   504
	int n = 0 ;	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   505
	do {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   506
		TFSNode* child = iFirstChild ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   507
		dup = false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   508
		while(child){		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   509
			if(0 == memcmp(rShortName,child->iShortName,11)) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   510
				dup = true ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   511
				break ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   512
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   513
			child = child->iSibling ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   514
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   515
		if(dup){ //duplex , increase the index , make a new name 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   516
			int nlen = sprintf(nstring,"~%u",++n);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   517
			while((baseNameLength + nlen > 8) && baseNameLength > 1)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   518
				baseNameLength -- ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   519
			memcpy(&rShortName[baseNameLength],nstring,nlen);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   520
			
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   521
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   522
	}while(dup) ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   523
		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   524
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   525