summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp18
-rw-r--r--indra/llimage/llimagej2c.cpp10
2 files changed, 15 insertions, 13 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index bfa129ea1d..88edc9943c 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -1513,7 +1513,9 @@ BOOL LLImageFormatted::load(const std::string &filename)
resetLastError();
S32 file_size = 0;
- apr_file_t* apr_file = ll_apr_file_open(filename, LL_APR_RB, &file_size);
+ LLAPRFile infile ;
+ infile.open(filename, LL_APR_RB, NULL, &file_size);
+ apr_file_t* apr_file = infile.getFileHandle();
if (!apr_file)
{
setLastError("Unable to open file for reading", filename);
@@ -1522,7 +1524,6 @@ BOOL LLImageFormatted::load(const std::string &filename)
if (file_size == 0)
{
setLastError("File is empty",filename);
- apr_file_close(apr_file);
return FALSE;
}
@@ -1540,8 +1541,7 @@ BOOL LLImageFormatted::load(const std::string &filename)
{
res = updateData();
}
- apr_file_close(apr_file);
-
+
return res;
}
@@ -1549,16 +1549,16 @@ BOOL LLImageFormatted::save(const std::string &filename)
{
resetLastError();
- apr_file_t* apr_file = ll_apr_file_open(filename, LL_APR_WB);
- if (!apr_file)
+ LLAPRFile outfile ;
+ outfile.open(filename, LL_APR_WB);
+ if (!outfile.getFileHandle())
{
setLastError("Unable to open file for writing", filename);
return FALSE;
}
- ll_apr_file_write(apr_file, getData(), getDataSize());
- apr_file_close(apr_file);
-
+ outfile.write(getData(), getDataSize());
+ outfile.close() ;
return TRUE;
}
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 52eb009cb7..1b93c21982 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -419,7 +419,9 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
resetLastError();
S32 file_size = 0;
- apr_file_t* apr_file = ll_apr_file_open(filename, LL_APR_RB, &file_size);
+ LLAPRFile infile ;
+ infile.open(filename, LL_APR_RB, NULL, &file_size);
+ apr_file_t* apr_file = infile.getFileHandle() ;
if (!apr_file)
{
setLastError("Unable to open file for reading", filename);
@@ -428,7 +430,6 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
else if (file_size == 0)
{
setLastError("File is empty",filename);
- apr_file_close(apr_file);
res = FALSE;
}
else
@@ -436,7 +437,8 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
U8 *data = new U8[file_size];
apr_size_t bytes_read = file_size;
apr_status_t s = apr_file_read(apr_file, data, &bytes_read); // modifies bytes_read
- apr_file_close(apr_file);
+ infile.close() ;
+
if (s != APR_SUCCESS || (S32)bytes_read != file_size)
{
delete[] data;
@@ -448,7 +450,7 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
res = validate(data, file_size);
}
}
-
+
if (!mLastError.empty())
{
LLImage::setLastError(mLastError);