Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
ec036d25
Commit
ec036d25
authored
Jun 06, 2018
by
Hugo Beauzée-Luyssen
Browse files
factory::IFileSystem -> fs::IFileSystemFactory
parent
6372a1da
Changes
20
Hide whitespace changes
Inline
Side-by-side
include/medialibrary/filesystem/IFileSystemFactory.h
View file @
ec036d25
...
...
@@ -33,14 +33,11 @@ namespace fs
class
IDirectory
;
class
IFile
;
class
IDevice
;
}
namespace
factory
{
class
IFileSystem
class
IFileSystemFactory
{
public:
virtual
~
IFileSystem
()
=
default
;
virtual
~
IFileSystem
Factory
()
=
default
;
///
/// \brief createDirectory creates a representation of a directory
/// \note This method can fail by throwing an exception if the
...
...
src/MediaLibrary.cpp
View file @
ec036d25
...
...
@@ -1200,7 +1200,7 @@ IDeviceListerCb* MediaLibrary::setDeviceLister( DeviceListerPtr lister )
return
static_cast
<
IDeviceListerCb
*>
(
this
);
}
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
MediaLibrary
::
fsFactoryForMrl
(
const
std
::
string
&
mrl
)
const
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
MediaLibrary
::
fsFactoryForMrl
(
const
std
::
string
&
mrl
)
const
{
for
(
const
auto
&
f
:
m_fsFactories
)
{
...
...
@@ -1221,7 +1221,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
#ifdef HAVE_LIBVLC
if
(
enabled
)
{
auto
it
=
std
::
find_if
(
begin
(
m_fsFactories
),
end
(
m_fsFactories
),
[](
const
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fs
)
{
auto
it
=
std
::
find_if
(
begin
(
m_fsFactories
),
end
(
m_fsFactories
),
[](
const
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fs
)
{
return
fs
->
isNetworkFileSystem
();
});
if
(
it
==
end
(
m_fsFactories
)
)
...
...
@@ -1229,7 +1229,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
}
else
{
m_fsFactories
.
erase
(
std
::
remove_if
(
begin
(
m_fsFactories
),
end
(
m_fsFactories
),
[](
const
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fs
)
{
m_fsFactories
.
erase
(
std
::
remove_if
(
begin
(
m_fsFactories
),
end
(
m_fsFactories
),
[](
const
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fs
)
{
return
fs
->
isNetworkFileSystem
();
}),
end
(
m_fsFactories
)
);
}
...
...
@@ -1279,7 +1279,7 @@ void MediaLibrary::setLogger( ILogger* logger )
Log
::
SetLogger
(
logger
);
}
void
MediaLibrary
::
refreshDevices
(
f
actory
::
IFileSystem
&
fsFactory
)
void
MediaLibrary
::
refreshDevices
(
f
s
::
IFileSystem
Factory
&
fsFactory
)
{
// Don't refuse to process devices when none seem to be present, it might be a valid case
// if the user only discovered removable storages, and we would still need to mark those
...
...
src/MediaLibrary.h
View file @
ec036d25
...
...
@@ -46,15 +46,11 @@ class Folder;
class
Genre
;
class
Playlist
;
namespace
factory
{
class
IFileSystem
;
}
namespace
fs
{
class
IFile
;
class
IDirectory
;
class
IFileSystemFactory
;
}
namespace
parser
...
...
@@ -160,9 +156,9 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
std
::
shared_ptr
<
ModificationNotifier
>
getNotifier
()
const
;
virtual
IDeviceListerCb
*
setDeviceLister
(
DeviceListerPtr
lister
)
override
;
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fsFactoryForMrl
(
const
std
::
string
&
path
)
const
;
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fsFactoryForMrl
(
const
std
::
string
&
path
)
const
;
void
refreshDevices
(
f
actory
::
IFileSystem
&
fsFactory
);
void
refreshDevices
(
f
s
::
IFileSystem
Factory
&
fsFactory
);
virtual
void
forceRescan
()
override
;
...
...
@@ -200,7 +196,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
void
registerEntityHooks
();
static
bool
validateSearchPattern
(
const
std
::
string
&
pattern
);
// Returns true if the device actually changed
bool
onDeviceChanged
(
f
actory
::
IFileSystem
&
fsFactory
,
Device
&
device
);
bool
onDeviceChanged
(
f
s
::
IFileSystem
Factory
&
fsFactory
,
Device
&
device
);
protected:
virtual
void
addLocalFsFactory
();
...
...
@@ -214,7 +210,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
protected:
std
::
shared_ptr
<
sqlite
::
Connection
>
m_dbConnection
;
std
::
vector
<
std
::
shared_ptr
<
f
actory
::
IFileSystem
>>
m_fsFactories
;
std
::
vector
<
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>>
m_fsFactories
;
std
::
string
m_thumbnailPath
;
IMediaLibraryCb
*
m_callback
;
DeviceListerPtr
m_deviceLister
;
...
...
src/discoverer/FsDiscoverer.cpp
View file @
ec036d25
...
...
@@ -58,7 +58,7 @@ public:
namespace
medialibrary
{
FsDiscoverer
::
FsDiscoverer
(
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fsFactory
,
MediaLibrary
*
ml
,
IMediaLibraryCb
*
cb
,
std
::
unique_ptr
<
prober
::
IProbe
>
probe
)
FsDiscoverer
::
FsDiscoverer
(
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fsFactory
,
MediaLibrary
*
ml
,
IMediaLibraryCb
*
cb
,
std
::
unique_ptr
<
prober
::
IProbe
>
probe
)
:
m_ml
(
ml
)
,
m_fsFactory
(
std
::
move
(
fsFactory
))
,
m_cb
(
cb
)
...
...
src/discoverer/FsDiscoverer.h
View file @
ec036d25
...
...
@@ -41,7 +41,7 @@ class IProbe;
class
FsDiscoverer
:
public
IDiscoverer
{
public:
FsDiscoverer
(
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fsFactory
,
MediaLibrary
*
ml
,
IMediaLibraryCb
*
cb
,
std
::
unique_ptr
<
prober
::
IProbe
>
probe
);
FsDiscoverer
(
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fsFactory
,
MediaLibrary
*
ml
,
IMediaLibraryCb
*
cb
,
std
::
unique_ptr
<
prober
::
IProbe
>
probe
);
virtual
bool
discover
(
const
std
::
string
&
entryPoint
)
override
;
virtual
bool
reload
()
override
;
virtual
bool
reload
(
const
std
::
string
&
entryPoint
)
override
;
...
...
@@ -61,7 +61,7 @@ private:
private:
MediaLibrary
*
m_ml
;
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
m_fsFactory
;
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
m_fsFactory
;
IMediaLibraryCb
*
m_cb
;
std
::
unique_ptr
<
prober
::
IProbe
>
m_probe
;
};
...
...
src/factory/FileSystemFactory.h
View file @
ec036d25
...
...
@@ -35,7 +35,7 @@ namespace medialibrary
namespace
factory
{
class
FileSystemFactory
:
public
IFileSystem
class
FileSystemFactory
:
public
fs
::
IFileSystem
Factory
{
// UUID -> Device instance map
using
DeviceCacheMap
=
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
fs
::
IDevice
>>
;
...
...
src/factory/NetworkFileSystemFactory.h
View file @
ec036d25
...
...
@@ -35,7 +35,7 @@ class IMediaLibraryCb;
namespace
factory
{
class
NetworkFileSystemFactory
:
public
f
actory
::
IFileSystem
class
NetworkFileSystemFactory
:
public
f
s
::
IFileSystem
Factory
{
public:
/**
...
...
src/filesystem/common/CommonDirectory.cpp
View file @
ec036d25
...
...
@@ -36,7 +36,7 @@ namespace medialibrary
namespace
fs
{
medialibrary
::
fs
::
CommonDirectory
::
CommonDirectory
(
f
actory
::
IFileSystem
&
fsFactory
)
medialibrary
::
fs
::
CommonDirectory
::
CommonDirectory
(
f
s
::
IFileSystem
Factory
&
fsFactory
)
:
m_fsFactory
(
fsFactory
)
{
}
...
...
src/filesystem/common/CommonDirectory.h
View file @
ec036d25
...
...
@@ -28,15 +28,15 @@
namespace
medialibrary
{
namespace
factory
{
class
IFileSystem
;
}
namespace
fs
{
class
IFileSystemFactory
;
class
CommonDirectory
:
public
IDirectory
{
public:
explicit
CommonDirectory
(
f
actory
::
IFileSystem
&
fsFactory
);
explicit
CommonDirectory
(
f
s
::
IFileSystem
Factory
&
fsFactory
);
virtual
const
std
::
vector
<
std
::
shared_ptr
<
IFile
>>&
files
()
const
override
;
virtual
const
std
::
vector
<
std
::
shared_ptr
<
IDirectory
>>&
dirs
()
const
override
;
virtual
std
::
shared_ptr
<
IDevice
>
device
()
const
override
;
...
...
@@ -48,7 +48,7 @@ protected:
mutable
std
::
vector
<
std
::
shared_ptr
<
IFile
>>
m_files
;
mutable
std
::
vector
<
std
::
shared_ptr
<
IDirectory
>>
m_dirs
;
mutable
Cache
<
std
::
shared_ptr
<
IDevice
>>
m_device
;
f
actory
::
IFileSystem
&
m_fsFactory
;
f
s
::
IFileSystem
Factory
&
m_fsFactory
;
};
}
...
...
src/filesystem/network/Directory.cpp
View file @
ec036d25
...
...
@@ -43,7 +43,7 @@ namespace medialibrary
namespace
fs
{
NetworkDirectory
::
NetworkDirectory
(
const
std
::
string
&
mrl
,
f
actory
::
IFileSystem
&
fsFactory
)
NetworkDirectory
::
NetworkDirectory
(
const
std
::
string
&
mrl
,
f
s
::
IFileSystem
Factory
&
fsFactory
)
:
CommonDirectory
(
fsFactory
)
,
m_mrl
(
utils
::
file
::
toFolderPath
(
mrl
)
)
{
...
...
src/filesystem/network/Directory.h
View file @
ec036d25
...
...
@@ -29,7 +29,7 @@ namespace fs
class
NetworkDirectory
:
public
CommonDirectory
{
public:
NetworkDirectory
(
const
std
::
string
&
mrl
,
f
actory
::
IFileSystem
&
fsFactory
);
NetworkDirectory
(
const
std
::
string
&
mrl
,
f
s
::
IFileSystem
Factory
&
fsFactory
);
virtual
const
std
::
string
&
mrl
()
const
override
;
private:
...
...
src/filesystem/unix/Directory.cpp
View file @
ec036d25
...
...
@@ -46,7 +46,7 @@ namespace medialibrary
namespace
fs
{
Directory
::
Directory
(
const
std
::
string
&
mrl
,
f
actory
::
IFileSystem
&
fsFactory
)
Directory
::
Directory
(
const
std
::
string
&
mrl
,
f
s
::
IFileSystem
Factory
&
fsFactory
)
:
CommonDirectory
(
fsFactory
)
{
m_path
=
utils
::
file
::
toFolderPath
(
toAbsolute
(
utils
::
file
::
toLocalPath
(
mrl
)
)
);
...
...
src/filesystem/unix/Directory.h
View file @
ec036d25
...
...
@@ -35,7 +35,7 @@ namespace fs
class
Directory
:
public
CommonDirectory
{
public:
Directory
(
const
std
::
string
&
mrl
,
f
actory
::
IFileSystem
&
fsFactory
);
Directory
(
const
std
::
string
&
mrl
,
f
s
::
IFileSystem
Factory
&
fsFactory
);
const
std
::
string
&
mrl
()
const
override
;
private:
...
...
src/filesystem/win32/Directory.cpp
View file @
ec036d25
...
...
@@ -43,7 +43,7 @@ namespace medialibrary
namespace
fs
{
Directory
::
Directory
(
const
std
::
string
&
mrl
,
f
actory
::
IFileSystem
&
fsFactory
)
Directory
::
Directory
(
const
std
::
string
&
mrl
,
f
s
::
IFileSystem
Factory
&
fsFactory
)
:
CommonDirectory
(
fsFactory
)
{
m_path
=
utils
::
file
::
toFolderPath
(
toAbsolute
(
utils
::
file
::
toLocalPath
(
mrl
)
)
);
...
...
src/filesystem/win32/Directory.h
View file @
ec036d25
...
...
@@ -33,7 +33,7 @@ namespace fs
class
Directory
:
public
CommonDirectory
{
public:
Directory
(
const
std
::
string
&
mrl
,
f
actory
::
IFileSystem
&
fsFactory
);
Directory
(
const
std
::
string
&
mrl
,
f
s
::
IFileSystem
Factory
&
fsFactory
);
const
std
::
string
&
mrl
()
const
override
;
private:
...
...
test/common/MediaLibraryTester.cpp
View file @
ec036d25
...
...
@@ -143,7 +143,7 @@ std::shared_ptr<Device> MediaLibraryTester::addDevice( const std::string& uuid,
return
Device
::
create
(
this
,
uuid
,
"file://"
,
isRemovable
);
}
void
MediaLibraryTester
::
setFsFactory
(
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fsf
)
void
MediaLibraryTester
::
setFsFactory
(
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fsf
)
{
fsFactory
=
fsf
;
}
...
...
test/common/MediaLibraryTester.h
View file @
ec036d25
...
...
@@ -54,7 +54,7 @@ public:
void
deleteGenre
(
int64_t
genreId
);
void
deleteArtist
(
int64_t
artistId
);
std
::
shared_ptr
<
Device
>
addDevice
(
const
std
::
string
&
uuid
,
bool
isRemovable
);
void
setFsFactory
(
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fsFactory
);
void
setFsFactory
(
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fsFactory
);
void
deleteTrack
(
int64_t
trackId
);
std
::
shared_ptr
<
AlbumTrack
>
albumTrack
(
int64_t
id
);
// Use to run tests that fiddles with file properties (modification dates, size...)
...
...
@@ -76,7 +76,7 @@ public:
private:
std
::
shared_ptr
<
fs
::
IDirectory
>
dummyDirectory
;
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fsFactory
;
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fsFactory
;
std
::
shared_ptr
<
Folder
>
dummyFolder
;
};
...
...
test/mocks/FileSystem.h
View file @
ec036d25
...
...
@@ -43,7 +43,7 @@
namespace
mock
{
struct
FileSystemFactory
:
public
f
actory
::
IFileSystem
struct
FileSystemFactory
:
public
f
s
::
IFileSystem
Factory
{
static
const
std
::
string
Root
;
static
const
std
::
string
SubFolder
;
...
...
@@ -344,7 +344,7 @@ class NoopDirectory : public fs::IDirectory
}
};
class
NoopFsFactory
:
public
f
actory
::
IFileSystem
class
NoopFsFactory
:
public
f
s
::
IFileSystem
Factory
{
public:
virtual
std
::
shared_ptr
<
fs
::
IDirectory
>
createDirectory
(
const
std
::
string
&
)
override
...
...
test/unittest/Tests.cpp
View file @
ec036d25
...
...
@@ -43,12 +43,12 @@ void Tests::TearDown()
ml
.
reset
();
}
void
Tests
::
Reload
(
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fs
/*= nullptr*/
,
IMediaLibraryCb
*
metadataCb
/*= nullptr*/
)
void
Tests
::
Reload
(
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fs
/*= nullptr*/
,
IMediaLibraryCb
*
metadataCb
/*= nullptr*/
)
{
InstantiateMediaLibrary
();
if
(
fs
==
nullptr
)
{
fs
=
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
(
new
mock
::
NoopFsFactory
);
fs
=
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
(
new
mock
::
NoopFsFactory
);
}
if
(
metadataCb
==
nullptr
)
{
...
...
test/unittest/Tests.h
View file @
ec036d25
...
...
@@ -33,11 +33,11 @@ class Tests : public testing::Test
protected:
std
::
unique_ptr
<
MediaLibraryTester
>
ml
;
std
::
unique_ptr
<
mock
::
NoopCallback
>
cbMock
;
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fsFactory
;
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fsFactory
;
std
::
shared_ptr
<
mock
::
MockDeviceLister
>
mockDeviceLister
;
virtual
void
SetUp
()
override
;
virtual
void
InstantiateMediaLibrary
();
void
Reload
(
std
::
shared_ptr
<
f
actory
::
IFileSystem
>
fs
=
nullptr
,
IMediaLibraryCb
*
metadataCb
=
nullptr
);
void
Reload
(
std
::
shared_ptr
<
f
s
::
IFileSystem
Factory
>
fs
=
nullptr
,
IMediaLibraryCb
*
metadataCb
=
nullptr
);
virtual
void
TearDown
()
override
;
};
Write
Preview
Supports
Markdown
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