|
From: <ust...@us...> - 2009-03-29 09:26:10
|
Revision: 2960
http://clucene.svn.sourceforge.net/clucene/?rev=2960&view=rev
Author: ustramooner
Date: 2009-03-29 09:26:05 +0000 (Sun, 29 Mar 2009)
Log Message:
-----------
fix realpath usage when directory doesn't exist
Modified Paths:
--------------
branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp
Modified: branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp 2009-03-29 08:54:12 UTC (rev 2959)
+++ branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp 2009-03-29 09:26:05 UTC (rev 2960)
@@ -353,10 +353,12 @@
refCount(0),
useMMap(LUCENE_USE_MMAP)
{
- directory = _realpath(path,directory);//set a realpath so that if we change directory, we can still function
- if ( !directory || !*directory ){
- strcpy(directory,path);
- }
+ char* tmpdirectory = _realpath(path,directory);//set a realpath so that if we change directory, we can still function
+ if ( !tmpdirectory || !*tmpdirectory ){
+ strncpy(directory,path, CL_MAX_PATH);
+ }else{
+ directory = tmpdirectory; //repoint tmpdirectory at directory
+ }
bool doClearLockID = false;
@@ -380,10 +382,10 @@
}
if (!Misc::dir_Exists(directory)){
- char* err = _CL_NEWARRAY(char,19+strlen(path)+1); //19: len of " is not a directory"
- strcpy(err,path);
- strcat(err," is not a directory");
- _CLTHROWA_DEL(CL_ERR_IO, err );
+ char* err = _CL_NEWARRAY(char,19+strlen(path)+1); //19: len of " is not a directory"
+ strcpy(err,path);
+ strcat(err," is not a directory");
+ _CLTHROWA_DEL(CL_ERR_IO, err );
}
}
@@ -391,7 +393,7 @@
void FSDirectory::create(){
SCOPED_LOCK_MUTEX(THIS_LOCK)
- struct cl_stat_t fstat;
+ struct cl_stat_t fstat;
if ( fileStat(directory,&fstat) != 0 ) {
//todo: should construct directory using _mkdirs... have to write replacement
if ( _mkdir(directory) == -1 ){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|