Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions indra/llappearanceutility/llappappearanceutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
#include "llprocesstexture.h"
#include "llprocessskin.h"

#include "apr_getopt.h"

const std::string NOTHING_EXTRA("");

////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion indra/llaudio/llaudiodecodemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ bool LLVorbisDecodeState::initDecode()
LL_DEBUGS("AudioEngine") << "Initing decode from vfile: " << mUUID << LL_ENDL;

mInFilep = new LLFileSystem(mUUID, LLAssetType::AT_SOUND);
if (!mInFilep || !mInFilep->getSize())
if (!mInFilep || mInFilep->getSize() <= 0)
{
LL_WARNS("AudioEngine") << "unable to open vorbis source vfile for reading" << LL_ENDL;
delete mInFilep;
Expand Down
1 change: 1 addition & 0 deletions indra/llcommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ if (LL_TESTS)
LL_ADD_INTEGRATION_TEST(lleventdispatcher "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lleventfilter "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llevents "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llfile "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llframetimer "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llhttpdate "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llheteromap "" "${test_libs}")
Expand Down
4 changes: 3 additions & 1 deletion indra/llcommon/llapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#endif

#include "llcommon.h"
#include "llapr.h"

#include "llerrorcontrol.h"
#include "llframetimer.h"
#include "lllivefile.h"
Expand All @@ -53,6 +53,8 @@
//
// Signal handling
#ifndef LL_WINDOWS
#include "apr_signal.h"

# include <signal.h>
# include <unistd.h> // for fork()
void setup_signals();
Expand Down
220 changes: 0 additions & 220 deletions indra/llcommon/llapr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,226 +526,6 @@ S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset)
}
}

//static
S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool)
{
LL_PROFILE_ZONE_SCOPED;
//*****************************************
LLAPRFilePoolScope scope(pool);
apr_file_t* file_handle = open(filename, scope.getVolatileAPRPool(), APR_READ|APR_BINARY);
//*****************************************
if (!file_handle)
{
return 0;
}

llassert(offset >= 0);

if (offset > 0)
offset = LLAPRFile::seek(file_handle, APR_SET, offset);

apr_size_t bytes_read;
if (offset < 0)
{
bytes_read = 0;
}
else
{
bytes_read = nbytes ;
apr_status_t s = apr_file_read(file_handle, buf, &bytes_read);
if (s != APR_SUCCESS)
{
LL_WARNS("APR") << " Attempting to read filename: " << filename << LL_ENDL;
ll_apr_warn_status(s);
bytes_read = 0;
}
else
{
llassert_always(bytes_read <= 0x7fffffff);
}
}

//*****************************************
close(file_handle) ;
//*****************************************
return (S32)bytes_read;
}

//static
S32 LLAPRFile::writeEx(const std::string& filename, const void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool)
{
LL_PROFILE_ZONE_SCOPED;
apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY;
if (offset < 0)
{
flags |= APR_APPEND;
offset = 0;
}

//*****************************************
LLAPRFilePoolScope scope(pool);
apr_file_t* file_handle = open(filename, scope.getVolatileAPRPool(), flags);
//*****************************************
if (!file_handle)
{
return 0;
}

if (offset > 0)
{
offset = LLAPRFile::seek(file_handle, APR_SET, offset);
}

apr_size_t bytes_written;
if (offset < 0)
{
bytes_written = 0;
}
else
{
bytes_written = nbytes ;
apr_status_t s = apr_file_write(file_handle, buf, &bytes_written);
if (s != APR_SUCCESS)
{
LL_WARNS("APR") << "Attempting to write filename: " << filename << LL_ENDL;
if (APR_STATUS_IS_ENOSPC(s))
{
LLApp::notifyOutOfDiskSpace();
}
ll_apr_warn_status(s);
bytes_written = 0;
}
else
{
llassert_always(bytes_written <= 0x7fffffff);
}
}

//*****************************************
LLAPRFile::close(file_handle);
//*****************************************

return (S32)bytes_written;
}

//static
bool LLAPRFile::remove(const std::string& filename, LLVolatileAPRPool* pool)
{
apr_status_t s;

LLAPRFilePoolScope scope(pool);
s = apr_file_remove(filename.c_str(), scope.getVolatileAPRPool());

if (s != APR_SUCCESS)
{
ll_apr_warn_status(s);
LL_WARNS("APR") << " Attempting to remove filename: " << filename << LL_ENDL;
return false;
}
return true;
}

//static
bool LLAPRFile::rename(const std::string& filename, const std::string& newname, LLVolatileAPRPool* pool)
{
apr_status_t s;

LLAPRFilePoolScope scope(pool);
s = apr_file_rename(filename.c_str(), newname.c_str(), scope.getVolatileAPRPool());

if (s != APR_SUCCESS)
{
ll_apr_warn_status(s);
LL_WARNS("APR") << " Attempting to rename filename: " << filename << LL_ENDL;
return false;
}
return true;
}

//static
bool LLAPRFile::isExist(const std::string& filename, LLVolatileAPRPool* pool, apr_int32_t flags)
{
apr_file_t* apr_file;
apr_status_t s;

LLAPRFilePoolScope scope(pool);
s = apr_file_open(&apr_file, filename.c_str(), flags, APR_OS_DEFAULT, scope.getVolatileAPRPool());

if (s != APR_SUCCESS || !apr_file)
{
return false;
}
else
{
apr_file_close(apr_file) ;
return true;
}
}

//static
S32 LLAPRFile::size(const std::string& filename, LLVolatileAPRPool* pool)
{
apr_file_t* apr_file;
apr_finfo_t info;
apr_status_t s;

LLAPRFilePoolScope scope(pool);
s = apr_file_open(&apr_file, filename.c_str(), APR_READ, APR_OS_DEFAULT, scope.getVolatileAPRPool());

if (s != APR_SUCCESS || !apr_file)
{
return 0;
}
else
{
apr_status_t s = apr_file_info_get(&info, APR_FINFO_SIZE, apr_file);

apr_file_close(apr_file) ;

if (s == APR_SUCCESS)
{
return (S32)info.size;
}
else
{
return 0;
}
}
}

//static
bool LLAPRFile::makeDir(const std::string& dirname, LLVolatileAPRPool* pool)
{
apr_status_t s;

LLAPRFilePoolScope scope(pool);
s = apr_dir_make(dirname.c_str(), APR_FPROT_OS_DEFAULT, scope.getVolatileAPRPool());

if (s != APR_SUCCESS)
{
ll_apr_warn_status(s);
LL_WARNS("APR") << " Attempting to make directory: " << dirname << LL_ENDL;
return false;
}
return true;
}

//static
bool LLAPRFile::removeDir(const std::string& dirname, LLVolatileAPRPool* pool)
{
apr_status_t s;

LLAPRFilePoolScope scope(pool);
s = apr_file_remove(dirname.c_str(), scope.getVolatileAPRPool());

if (s != APR_SUCCESS)
{
ll_apr_warn_status(s);
LL_WARNS("APR") << " Attempting to remove directory: " << dirname << LL_ENDL;
return false;
}
return true;
}
//
//end of static components of LLAPRFile
//*******************************************************************************************************************************
Expand Down
19 changes: 0 additions & 19 deletions indra/llcommon/llapr.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@

#include "llwin32headers.h"
#include "apr_thread_proc.h"
#include "apr_getopt.h"
#include "apr_signal.h"

#include "llstring.h"

#include "mutex.h"

struct apr_dso_handle_t;
/**
Expand Down Expand Up @@ -184,20 +178,7 @@ class LL_COMMON_API LLAPRFile
static apr_file_t* open(const std::string& filename, apr_pool_t* apr_pool, apr_int32_t flags);
static apr_status_t close(apr_file_t* file) ;
static S32 seek(apr_file_t* file, apr_seek_where_t where, S32 offset);
public:
// returns false if failure:
static bool remove(const std::string& filename, LLVolatileAPRPool* pool = NULL);
static bool rename(const std::string& filename, const std::string& newname, LLVolatileAPRPool* pool = NULL);
static bool isExist(const std::string& filename, LLVolatileAPRPool* pool = NULL, apr_int32_t flags = APR_READ);
static S32 size(const std::string& filename, LLVolatileAPRPool* pool = NULL);
static bool makeDir(const std::string& dirname, LLVolatileAPRPool* pool = NULL);
static bool removeDir(const std::string& dirname, LLVolatileAPRPool* pool = NULL);

// Returns bytes read/written, 0 if read/write fails:
static S32 readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL);
static S32 writeEx(const std::string& filename, const void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); // offset<0 means append
//*******************************************************************************************************************************
};


#endif // LL_LLAPR_H
10 changes: 3 additions & 7 deletions indra/llcommon/llerror.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,9 @@ namespace

std::string file = user_dir + "/logcontrol-dev.xml";

llstat stat_info;
if (LLFile::stat(file, &stat_info)) {
// NB: stat returns non-zero if it can't read the file, for example
// if it doesn't exist. LLFile has no better abstraction for
// testing for file existence.

file = app_dir + "/logcontrol.xml";
if (!LLFile::isfile(file))
{
file = app_dir + "/logcontrol.xml";
}
return * new LogControlFile(file);
// NB: This instance is never freed
Expand Down
Loading