Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
03fb833c
Commit
03fb833c
authored
Jan 24, 2016
by
Hugo Beauzée-Luyssen
Browse files
fs: Use a shared_ptr to manage files
parent
5171b0a2
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/factory/IFileSystem.h
View file @
03fb833c
...
...
@@ -47,7 +47,7 @@ namespace factory
/// \brief createFile creates a representation of a file
/// \param fileName an absolute path to a file
///
virtual
std
::
unique
_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
fileName
)
=
0
;
virtual
std
::
shared
_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
fileName
)
=
0
;
///
/// \brief createDevice creates a representation of a device
/// \param uuid The device UUID
...
...
src/MediaLibrary.cpp
View file @
03fb833c
...
...
@@ -203,7 +203,7 @@ std::vector<MediaPtr> MediaLibrary::videoFiles()
std
::
shared_ptr
<
Media
>
MediaLibrary
::
addFile
(
const
std
::
string
&
path
,
Folder
&
parentFolder
,
fs
::
IDirectory
&
parentFolderFs
)
{
std
::
unique
_ptr
<
fs
::
IFile
>
fileFs
;
std
::
shared
_ptr
<
fs
::
IFile
>
fileFs
;
try
{
fileFs
=
m_fsFactory
->
createFile
(
path
);
...
...
src/factory/FileSystem.cpp
View file @
03fb833c
...
...
@@ -62,7 +62,7 @@ std::shared_ptr<fs::IDirectory> FileSystemFactory::createDirectory( const std::s
}
}
std
::
unique
_ptr
<
fs
::
IFile
>
FileSystemFactory
::
createFile
(
const
std
::
string
&
fileName
)
std
::
shared
_ptr
<
fs
::
IFile
>
FileSystemFactory
::
createFile
(
const
std
::
string
&
fileName
)
{
return
std
::
unique_ptr
<
fs
::
IFile
>
(
new
fs
::
File
(
fileName
)
);
}
...
...
src/factory/FileSystem.h
View file @
03fb833c
...
...
@@ -35,7 +35,7 @@ namespace factory
public:
FileSystemFactory
();
virtual
std
::
shared_ptr
<
fs
::
IDirectory
>
createDirectory
(
const
std
::
string
&
path
)
override
;
virtual
std
::
unique
_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
fileName
)
override
;
virtual
std
::
shared
_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
fileName
)
override
;
virtual
std
::
shared_ptr
<
fs
::
IDevice
>
createDevice
(
const
std
::
string
&
uuid
)
override
;
virtual
void
refresh
()
override
;
...
...
test/mocks/FileSystem.h
View file @
03fb833c
...
...
@@ -443,15 +443,13 @@ struct FileSystemFactory : public factory::IFileSystem
return
d
->
directory
(
path
);
}
virtual
std
::
unique
_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
filePath
)
override
virtual
std
::
shared
_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
filePath
)
override
{
auto
d
=
device
(
filePath
);
if
(
d
==
nullptr
)
return
nullptr
;
auto
f
=
d
->
file
(
filePath
);
if
(
f
==
nullptr
)
return
nullptr
;
return
std
::
unique_ptr
<
fs
::
IFile
>
(
new
File
(
*
f
)
);
return
f
;
}
virtual
std
::
shared_ptr
<
fs
::
IDevice
>
createDevice
(
const
std
::
string
&
uuid
)
override
...
...
@@ -592,9 +590,9 @@ public:
return
nullptr
;
}
virtual
std
::
unique
_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
fileName
)
override
virtual
std
::
shared
_ptr
<
fs
::
IFile
>
createFile
(
const
std
::
string
&
fileName
)
override
{
return
std
::
unique
_ptr
<
fs
::
IFile
>
(
new
NoopFile
(
fileName
)
);
return
std
::
shared
_ptr
<
fs
::
IFile
>
(
new
NoopFile
(
fileName
)
);
}
virtual
std
::
shared_ptr
<
fs
::
IDevice
>
createDevice
(
const
std
::
string
&
)
override
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment