bintools/rcomp/src/FILEACC.CPP
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <stdlib.h>
       
    20 #include <assert.h>
       
    21 #include <string.h>
       
    22 #include "FILEACC.H"
       
    23 
       
    24 #ifdef __LINUX__
       
    25 #include <linux/limits.h>
       
    26 #include <stdlib.h>
       
    27 #include <libgen.h>
       
    28 #endif //__LINUX__
       
    29 
       
    30 // The functions in this class use non-standard run-time routines e.g. _fullpath.
       
    31 
       
    32 String FileAccess::FullPath(const String& aPartialPath)
       
    33 	{
       
    34 #ifndef __LINUX__
       
    35 	char path[_MAX_PATH];
       
    36 	if(aPartialPath.Length()==0)
       
    37 		assert(_fullpath(path,"",_MAX_PATH)!=NULL);
       
    38 	else
       
    39 		assert(_fullpath(path,aPartialPath.GetAssertedNonEmptyBuffer(),_MAX_PATH)!=NULL);
       
    40 	return path;
       
    41 #else
       
    42 	char path[PATH_MAX];
       
    43 	if (aPartialPath.Length() == 0)
       
    44 		assert(realpath("", path) != NULL);
       
    45 	else
       
    46 		assert(realpath(aPartialPath.GetAssertedNonEmptyBuffer(), path) != NULL);
       
    47 	return path;
       
    48 #endif
       
    49 	}
       
    50 
       
    51 String FileAccess::GetDriveAndDirectory(const String& aFullFileName)
       
    52 	{
       
    53 #ifndef __LINUX__
       
    54 	char drive[_MAX_DRIVE];
       
    55 	char directory[_MAX_DIR];
       
    56 	char filename[_MAX_FNAME];
       
    57 	char extension[_MAX_EXT];
       
    58 	_splitpath(aFullFileName.GetAssertedNonEmptyBuffer(),drive,directory,filename,extension);
       
    59 	char path[_MAX_PATH];
       
    60 	strcpy(path,drive);
       
    61 	strcpy(path+strlen(path),directory);
       
    62 	return path;
       
    63 #else
       
    64 	return dirname(const_cast<char*>(aFullFileName.GetAssertedNonEmptyBuffer()));
       
    65 #endif //__LINUX__
       
    66 	}
       
    67