Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
XDG Integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
JennaHuntsman
XDG Integration
Commits
1b8caf51
Commit
1b8caf51
authored
4 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Replace C++ stream io with C io in LLFileSystem
parent
88a4d9c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llfilesystem/llfilesystem.cpp
+41
-27
41 additions, 27 deletions
indra/llfilesystem/llfilesystem.cpp
with
41 additions
and
27 deletions
indra/llfilesystem/llfilesystem.cpp
+
41
−
27
View file @
1b8caf51
...
@@ -52,11 +52,10 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil
...
@@ -52,11 +52,10 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil
{
{
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
file_id
,
file_type
);
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
file_id
,
file_type
);
ll
ifstream
file
(
filename
,
std
::
ios
::
binary
)
;
ll
stat
stat
;
if
(
file
.
is_open
()
)
if
(
LLFile
::
stat
(
filename
,
&
stat
)
==
0
)
{
{
file
.
seekg
(
0
,
std
::
ios
::
end
);
return
S_ISREG
(
stat
.
st_mode
)
&&
stat
.
st_size
>
0
;
return
file
.
tellg
()
>
0
;
}
}
return
false
;
return
false
;
}
}
...
@@ -99,11 +98,10 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi
...
@@ -99,11 +98,10 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
file_id
,
file_type
);
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
file_id
,
file_type
);
S32
file_size
=
0
;
S32
file_size
=
0
;
ll
ifstream
file
(
filename
,
std
::
ios
::
binary
)
;
ll
stat
stat
;
if
(
file
.
is_open
()
)
if
(
LLFile
::
stat
(
filename
,
&
stat
)
==
0
)
{
{
file
.
seekg
(
0
,
std
::
ios
::
end
);
file_size
=
stat
.
st_size
;
file_size
=
file
.
tellg
();
}
}
return
file_size
;
return
file_size
;
...
@@ -115,29 +113,45 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes)
...
@@ -115,29 +113,45 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes)
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
mFileID
,
mFileType
);
const
std
::
string
filename
=
LLDiskCache
::
getInstance
()
->
metaDataToFilepath
(
mFileID
,
mFileType
);
llifstream
file
(
filename
,
std
::
ios
::
binary
);
LLUniqueFile
filep
=
LLFile
::
fopen
(
filename
,
"rb"
);
if
(
file
.
is_open
()
)
if
(
file
p
)
{
{
file
.
seekg
(
mPosition
,
std
::
ios
::
beg
);
fseek
(
filep
,
mPosition
,
SEEK_SET
);
if
(
fread
((
void
*
)
buffer
,
bytes
,
1
,
filep
)
>
0
)
file
.
read
((
char
*
)
buffer
,
bytes
);
if
(
file
)
{
{
mBytesRead
=
bytes
;
mBytesRead
=
bytes
;
}
}
else
else
{
{
mBytesRead
=
file
.
gcount
();
fseek
(
filep
,
0L
,
SEEK_END
);
long
fsize
=
ftell
(
filep
);
fseek
(
filep
,
mPosition
,
SEEK_SET
);
if
(
mPosition
<
fsize
)
{
long
rsize
=
fsize
-
mPosition
;
if
(
fread
((
void
*
)
buffer
,
rsize
,
1
,
filep
)
>
0
)
{
mBytesRead
=
rsize
;
}
else
{
success
=
FALSE
;
}
}
else
{
success
=
FALSE
;
}
}
}
file
.
close
();
if
(
!
success
)
mPosition
+=
mBytesRead
;
if
(
!
mBytesRead
)
{
{
success
=
FALSE
;
mBytesRead
=
0
;
}
}
filep
.
close
();
mPosition
+=
mBytesRead
;
}
}
// update the last access time for the file - this is required
// update the last access time for the file - this is required
...
@@ -167,20 +181,20 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes)
...
@@ -167,20 +181,20 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes)
if
(
mMode
==
APPEND
)
if
(
mMode
==
APPEND
)
{
{
llofstream
ofs
(
filename
,
std
::
ios
::
app
|
std
::
ios
::
binary
);
LLUniqueFile
filep
=
LLFile
::
fopen
(
filename
,
"ab"
);
if
(
ofs
)
if
(
filep
)
{
{
ofs
.
write
((
const
char
*
)
buffer
,
bytes
);
f
write
((
const
void
*
)
buffer
,
bytes
,
1
,
filep
);
success
=
TRUE
;
success
=
TRUE
;
}
}
}
}
else
else
{
{
llofstream
ofs
(
filename
,
std
::
ios
::
binary
);
LLUniqueFile
filep
=
LLFile
::
fopen
(
filename
,
"wb"
);
if
(
ofs
)
if
(
filep
)
{
{
ofs
.
write
((
const
char
*
)
buffer
,
bytes
);
f
write
((
const
void
*
)
buffer
,
bytes
,
1
,
filep
);
mPosition
+=
bytes
;
mPosition
+=
bytes
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment