summaryrefslogtreecommitdiff
path: root/l10ntools/source/directory.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'l10ntools/source/directory.cxx')
-rw-r--r--l10ntools/source/directory.cxx68
1 files changed, 34 insertions, 34 deletions
diff --git a/l10ntools/source/directory.cxx b/l10ntools/source/directory.cxx
index bca2e399170c..d83fa8bfedb8 100644
--- a/l10ntools/source/directory.cxx
+++ b/l10ntools/source/directory.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -35,7 +35,7 @@
#include <vector>
#include <algorithm>
-namespace transex
+namespace transex
{
Directory::Directory( const rtl::OUString sFullpath ) : bSkipLinks( false )
@@ -57,16 +57,16 @@ Directory::Directory( const ByteString sFullPath ) : bSkipLinks( false )
bool Directory::lessDir ( const Directory& rKey1, const Directory& rKey2 )
{
- rtl::OUString sName1( ( static_cast< Directory >( rKey1 ) ).getDirectoryName() );
- rtl::OUString sName2( ( static_cast< Directory >( rKey2 ) ).getDirectoryName() );
-
+ rtl::OUString sName1( ( static_cast< Directory >( rKey1 ) ).getDirectoryName() );
+ rtl::OUString sName2( ( static_cast< Directory >( rKey2 ) ).getDirectoryName() );
+
return sName1.compareTo( sName2 ) < 0 ;
}
void Directory::dump()
{
-
+
for( std::vector< transex::File >::iterator iter = aFileVec.begin() ; iter != aFileVec.end() ; ++iter )
{
std::cout << "FILE " << rtl::OUStringToOString( (*iter).getFullName().getStr() , RTL_TEXTENCODING_UTF8 , (*iter).getFullName().getLength() ).getStr() << "\n";
@@ -76,7 +76,7 @@ void Directory::dump()
{
std::cout << "DIR " << rtl::OUStringToOString( (*iter).getFullName().getStr() , RTL_TEXTENCODING_UTF8 , (*iter).getFullName().getLength() ).getStr() << "\n";
}
-
+
}
void Directory::scanSubDir( int nLevels )
@@ -116,14 +116,14 @@ void Directory::readDirectory ( const rtl::OUString& sFullpath )
rtl::OString sFullpathext = rtl::OUStringToOString( sFullpath , RTL_TEXTENCODING_UTF8 , sFullpath.getLength() );
const char *dirname = sFullpathext.getStr();
-
+
// Get the proper directory path
sprintf(szDir, "%s\\*", dirname);
-
+
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
- {
+ {
//FindClose(hList);
//printf("No files found %s\n", szDir ); return;
}
@@ -132,7 +132,7 @@ void Directory::readDirectory ( const rtl::OUString& sFullpath )
fFinished = FALSE;
while (!fFinished)
{
-
+
sprintf(szSubDir, "%s\\%s", dirname, FileData.cFileName);
rtl::OString myfile( FileData.cFileName );
rtl::OString mydir( szSubDir );
@@ -143,14 +143,14 @@ void Directory::readDirectory ( const rtl::OUString& sFullpath )
(strcmp(FileData.cFileName, "..") != 0 ) )
{
//sprintf(szSubDir, "%s\\%s", dirname, FileData.cFileName);
- transex::Directory aDir( rtl::OStringToOUString( mydir , RTL_TEXTENCODING_UTF8 , mydir.getLength() ),
+ transex::Directory aDir( rtl::OStringToOUString( mydir , RTL_TEXTENCODING_UTF8 , mydir.getLength() ),
rtl::OStringToOUString( myfile , RTL_TEXTENCODING_UTF8 , myfile.getLength() ) );
aDirVec.push_back( aDir );
}
}
else
{
- transex::File aFile( rtl::OStringToOUString( mydir , RTL_TEXTENCODING_UTF8 , mydir.getLength() ),
+ transex::File aFile( rtl::OStringToOUString( mydir , RTL_TEXTENCODING_UTF8 , mydir.getLength() ),
rtl::OStringToOUString( myfile , RTL_TEXTENCODING_UTF8 , myfile.getLength() ) );
aFileVec.push_back( aFile );
}
@@ -165,7 +165,7 @@ void Directory::readDirectory ( const rtl::OUString& sFullpath )
}
FindClose(hList);
-
+
::std::sort( aFileVec.begin() , aFileVec.end() , File::lessFile );
::std::sort( aDirVec.begin() , aDirVec.end() , Directory::lessDir );
}
@@ -193,20 +193,20 @@ void Directory::readDirectory( const rtl::OUString& sFullpath )
rtl::OString sFullpathext = rtl::OUStringToOString( sFullpath , RTL_TEXTENCODING_UTF8 );
const char* path = sFullpathext.getStr();
-
+
// stat
if( stat( path , &statbuf ) < 0 ){ printf("warning: Can not stat %s" , path ); return; }
-
+
if( S_ISDIR(statbuf.st_mode ) == 0 ) { return; }
if( (dir = opendir( path ) ) == NULL ) {printf("readerror 2 in %s \n",path); return; }
dirholder aHolder(dir);
-
+
const rtl::OString sDot ( "." ) ;
const rtl::OString sDDot( ".." );
-
+
if ( chdir( path ) == -1 ) { printf("chdir error in %s \n",path); return; }
-
+
sFullpathext += rtl::OString( "/" );
while( ( dirp = readdir( dir ) ) != NULL )
@@ -215,11 +215,11 @@ void Directory::readDirectory( const rtl::OUString& sFullpath )
if( sEntryName.equals( sDot ) || sEntryName.equals( sDDot ) )
continue;
-
+
// add dir entry
rtl::OString sEntity = sFullpathext;
sEntity += sEntryName;
-
+
// stat new entry
if( lstat( sEntity.getStr() , &statbuf2 ) < 0 )
{
@@ -231,31 +231,31 @@ void Directory::readDirectory( const rtl::OUString& sFullpath )
switch( statbuf2.st_mode & S_IFMT )
{
case S_IFREG:
- {
+ {
rtl::OString sFile = sFullpathext;
sFile += sEntryName ;
- transex::File aFile( rtl::OStringToOUString( sEntity , RTL_TEXTENCODING_UTF8 , sEntity.getLength() ) ,
- rtl::OStringToOUString( sEntryName , RTL_TEXTENCODING_UTF8 , sEntryName.getLength() )
+ transex::File aFile( rtl::OStringToOUString( sEntity , RTL_TEXTENCODING_UTF8 , sEntity.getLength() ) ,
+ rtl::OStringToOUString( sEntryName , RTL_TEXTENCODING_UTF8 , sEntryName.getLength() )
);
- aFileVec.push_back( aFile ) ;
- break;
- }
+ aFileVec.push_back( aFile ) ;
+ break;
+ }
case S_IFLNK:
- {
+ {
if( bSkipLinks ) break;
}
case S_IFDIR:
- {
+ {
rtl::OString sDir = sFullpathext;
sDir += sEntryName ;
- transex::Directory aDir(
+ transex::Directory aDir(
rtl::OStringToOUString( sEntity , RTL_TEXTENCODING_UTF8 , sEntity.getLength() ) ,
- rtl::OStringToOUString( sEntryName , RTL_TEXTENCODING_UTF8 , sEntryName.getLength() )
- ) ;
- aDirVec.push_back( aDir ) ;
- break;
+ rtl::OStringToOUString( sEntryName , RTL_TEXTENCODING_UTF8 , sEntryName.getLength() )
+ ) ;
+ aDirVec.push_back( aDir ) ;
+ break;
}
}
}