[babca8]: xbmc / FileSystem / IDirectory.cpp  Maximize  Restore  History

Repo status: analyzing...

Download this file

133 lines (110 with data), 3.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "IDirectory.h"
#include "Util.h"
using namespace DIRECTORY;
IDirectory::IDirectory(void)
{
m_strFileMask = "";
m_allowPrompting = false;
m_cacheDirectory = false;
m_useFileDirectories = false;
m_extFileInfo = true;
}
IDirectory::~IDirectory(void)
{}
/*!
\brief Test a file for an extension specified with SetMask().
\param strFile File to test
\return Returns \e true, if file is allowed.
*/
bool IDirectory::IsAllowed(const CStdString& strFile) const
{
CStdString strExtension;
if ( !m_strFileMask.size() ) return true;
if ( !strFile.size() ) return true;
CUtil::GetExtension(strFile, strExtension);
if (!strExtension.size()) return false;
strExtension.ToLower();
// ignore all non dvd related ifo files.
if (strExtension.Equals(".ifo"))
{
if (strFile.Equals("video_ts.ifo")) return true;
if (strFile.Left(4).Equals("vts_") && strFile.Right(6).Equals("_0.ifo") && strFile.length() == 12) return true;
return false;
}
strExtension += '|'; // ensures that we have a | at the end of it
if (m_strFileMask.Find(strExtension) != (size_t)CStdString::npos)
return true;
return false;
}
/*!
\brief Set a mask of extensions for the files in the directory.
\param strMask Mask of file extensions that are allowed.
The mask has to look like the following: \n
\verbatim
.m4a|.flac|.aac|
\endverbatim
So only *.m4a, *.flac, *.aac files will be retrieved with GetDirectory().
*/
void IDirectory::SetMask(const CStdString& strMask)
{
m_strFileMask = strMask;
// ensure it's completed with a | so that filtering is easy.
m_strFileMask.ToLower();
if (m_strFileMask.size() && m_strFileMask[m_strFileMask.size() - 1] != '|')
m_strFileMask += '|';
}
/*!
\brief Set whether the directory handlers can prompt the user.
\param allowPrompting Set true to allow prompting to occur (default is false).
Directory handlers should only prompt the user as a direct result of the
users actions.
*/
void IDirectory::SetAllowPrompting(bool allowPrompting)
{
m_allowPrompting = allowPrompting;
}
/*!
\brief Set whether the directory should be cached by our directory cache.
\param cacheDirectory Set true to enable caching (default is false).
*/
void IDirectory::SetCacheDirectory(bool cacheDirectory)
{
m_cacheDirectory = cacheDirectory;
}
/*!
\brief Set whether the directory should allow file directories.
\param useFileDirectories Set true to enable file directories (default is true).
*/
void IDirectory::SetUseFileDirectories(bool useFileDirectories)
{
m_useFileDirectories = useFileDirectories;
}
/*!
\brief Set whether the GetDirectory call will retrieve extended file information (stat calls for example).
\param extFileInfo Set true to enable extended file info (default is true).
*/
void IDirectory::SetExtFileInfo(bool extFileInfo)
{
m_extFileInfo = extFileInfo;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks