Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d229e1f4
authored
Mar 18, 2019
by
eguven
Committed by
Oliver Woodman
Mar 20, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add helper methods to check existence and delete ActionFiles
PiperOrigin-RevId: 239002281
parent
a5616cb5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/ActionFile.java
library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java
library/core/src/main/java/com/google/android/exoplayer2/offline/ActionFile.java
View file @
d229e1f4
...
@@ -31,13 +31,11 @@ public final class ActionFile {
...
@@ -31,13 +31,11 @@ public final class ActionFile {
/* package */
static
final
int
VERSION
=
0
;
/* package */
static
final
int
VERSION
=
0
;
private
final
AtomicFile
atomicFile
;
private
final
AtomicFile
atomicFile
;
private
final
File
actionFile
;
/**
/**
* @param actionFile File to be used to store and load {@link DownloadAction}s.
* @param actionFile File to be used to store and load {@link DownloadAction}s.
*/
*/
public
ActionFile
(
File
actionFile
)
{
public
ActionFile
(
File
actionFile
)
{
this
.
actionFile
=
actionFile
;
atomicFile
=
new
AtomicFile
(
actionFile
);
atomicFile
=
new
AtomicFile
(
actionFile
);
}
}
...
@@ -48,7 +46,7 @@ public final class ActionFile {
...
@@ -48,7 +46,7 @@ public final class ActionFile {
* @throws IOException If there is an error during loading.
* @throws IOException If there is an error during loading.
*/
*/
public
DownloadAction
[]
load
()
throws
IOException
{
public
DownloadAction
[]
load
()
throws
IOException
{
if
(!
actionFile
.
exists
())
{
if
(!
exists
())
{
return
new
DownloadAction
[
0
];
return
new
DownloadAction
[
0
];
}
}
InputStream
inputStream
=
null
;
InputStream
inputStream
=
null
;
...
@@ -93,4 +91,13 @@ public final class ActionFile {
...
@@ -93,4 +91,13 @@ public final class ActionFile {
}
}
}
}
/** Returns whether the file or its backup exists. */
public
boolean
exists
()
{
return
atomicFile
.
exists
();
}
/** Delete the action file and its backup. */
public
void
delete
()
{
atomicFile
.
delete
();
}
}
}
library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java
View file @
d229e1f4
...
@@ -52,7 +52,7 @@ public final class AtomicFile {
...
@@ -52,7 +52,7 @@ public final class AtomicFile {
backupName
=
new
File
(
baseName
.
getPath
()
+
".bak"
);
backupName
=
new
File
(
baseName
.
getPath
()
+
".bak"
);
}
}
/**
W
hether the file or its backup exists. */
/**
Returns w
hether the file or its backup exists. */
public
boolean
exists
()
{
public
boolean
exists
()
{
return
baseName
.
exists
()
||
backupName
.
exists
();
return
baseName
.
exists
()
||
backupName
.
exists
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment