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
8c8f8b56
Commit
8c8f8b56
authored
2 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
C file io for the sadcache
parent
90ef1ca9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llfilesystem/llfilesystem.cpp
+46
-54
46 additions, 54 deletions
indra/llfilesystem/llfilesystem.cpp
with
46 additions
and
54 deletions
indra/llfilesystem/llfilesystem.cpp
+
46
−
54
View file @
8c8f8b56
...
...
@@ -77,13 +77,12 @@ LLFileSystem::~LLFileSystem()
bool
LLFileSystem
::
getExists
(
const
LLUUID
&
file_id
,
const
LLAssetType
::
EType
file_type
)
{
const
std
::
string
filename
=
LLDiskCache
::
metaDataToFilepath
(
file_id
,
file_type
);
llifstream
file
(
filename
,
std
::
ios
::
binary
);
if
(
file
.
is_open
())
llstat
file_stat
;
if
(
LLFile
::
stat
(
filename
,
&
file_stat
)
==
0
)
{
file
.
seekg
(
0
,
std
::
ios
::
end
);
return
file
.
tellg
()
>
0
;
return
S_ISREG
(
file_stat
.
st_mode
)
&&
file_stat
.
st_size
>
0
;
}
return
false
;
}
...
...
@@ -125,13 +124,13 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi
const
std
::
string
filename
=
LLDiskCache
::
metaDataToFilepath
(
file_id
,
file_type
);
S32
file_size
=
0
;
ll
ifstream
file
(
filename
,
std
::
ios
::
binary
)
;
if
(
file
.
is_open
()
)
ll
stat
file_stat
;
if
(
LLFile
::
stat
(
filename
,
&
file_stat
)
==
0
)
{
file
.
seekg
(
0
,
std
::
ios
::
end
);
file_size
=
file
.
tellg
();
file_size
=
file_stat
.
st_size
;
}
return
file_size
;
}
...
...
@@ -141,31 +140,25 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes)
const
std
::
string
filename
=
LLDiskCache
::
metaDataToFilepath
(
mFileID
,
mFileType
);
llifstream
file
(
filename
,
std
::
ios
::
binary
);
if
(
file
.
is_open
()
)
LLFILE
*
file
=
LLFile
::
fopen
(
filename
,
"rb"
);
if
(
file
)
{
file
.
seekg
(
mPosition
,
std
::
ios
::
beg
);
file
.
read
((
char
*
)
buffer
,
bytes
);
if
(
file
)
{
mBytesRead
=
bytes
;
}
else
if
(
fseek
(
file
,
mPosition
,
SEEK_SET
)
==
0
)
{
mBytesRead
=
f
ile
.
gcount
(
);
}
mBytesRead
=
f
read
(
buffer
,
1
,
bytes
,
file
);
fclose
(
file
);
file
.
close
();
mPosition
+=
mBytesRead
;
if
(
mBytesRead
)
{
success
=
TRUE
;
mPosition
+=
mBytesRead
;
// It probably would be correct to check for mBytesRead == bytes,
// but that will break avatar rezzing...
if
(
mBytesRead
)
{
success
=
TRUE
;
}
}
}
return
success
;
}
...
...
@@ -187,54 +180,53 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes)
if
(
mMode
==
APPEND
)
{
llofstream
ofs
(
filename
,
std
::
ios
::
app
|
std
::
ios
::
binary
);
LLFILE
*
ofs
=
LLFile
::
fopen
(
filename
,
"a+b"
);
if
(
ofs
)
{
ofs
.
write
((
const
char
*
)
buffer
,
bytes
);
mPosition
=
ofs
.
tellp
();
// <FS:Ansariel> Fix asset caching
success
=
TRUE
;
S32
bytes_written
=
fwrite
(
buffer
,
1
,
bytes
,
ofs
);
mPosition
=
ftell
(
ofs
);
fclose
(
ofs
);
success
=
(
bytes_written
==
bytes
);
}
}
// <FS:Ansariel> Fix asset caching
else
if
(
mMode
==
READ_WRITE
)
{
// Don't truncate if file already exists
llofstream
ofs
(
filename
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
LLFILE
*
ofs
=
LLFile
::
fopen
(
filename
,
"r+b"
);
if
(
ofs
)
{
ofs
.
seekp
(
mPosition
,
std
::
ios
::
beg
);
ofs
.
write
((
const
char
*
)
buffer
,
bytes
);
mPosition
+=
bytes
;
success
=
TRUE
;
if
(
fseek
(
ofs
,
mPosition
,
SEEK_SET
)
==
0
)
{
S32
bytes_written
=
fwrite
(
buffer
,
1
,
bytes
,
ofs
);
mPosition
=
ftell
(
ofs
);
fclose
(
ofs
);
success
=
(
bytes_written
==
bytes
);
}
}
else
{
// File doesn't exist - open in write mode
ofs
.
open
(
filename
,
std
::
ios
::
binary
);
if
(
ofs
.
is_open
())
ofs
=
LLFile
::
fopen
(
filename
,
"wb"
);
if
(
ofs
)
{
ofs
.
write
((
const
char
*
)
buffer
,
bytes
);
mPosition
+=
bytes
;
success
=
TRUE
;
S32
bytes_written
=
fwrite
(
buffer
,
1
,
bytes
,
ofs
);
mPosition
=
ftell
(
ofs
);
fclose
(
ofs
);
success
=
(
bytes_written
==
bytes
);
}
}
}
// </FS:Ansariel>
else
{
llofstream
ofs
(
filename
,
std
::
ios
::
binary
);
LLFILE
*
ofs
=
LLFile
::
fopen
(
filename
,
"wb"
);
if
(
ofs
)
{
ofs
.
write
((
const
char
*
)
buffer
,
bytes
);
mPosition
+=
bytes
;
success
=
TRUE
;
S32
bytes_written
=
fwrite
(
buffer
,
1
,
bytes
,
ofs
);
mPosition
=
ftell
(
ofs
);
fclose
(
ofs
);
success
=
(
bytes_written
==
bytes
);
}
}
return
success
;
}
...
...
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