Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
a699927c
Kaydet (Commit)
a699927c
authored
May 13, 2014
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Elide utl::TempFile_Impl
Change-Id: I8f14cd351c17abaa9d48144cdf8325afc250787b
üst
404e4d61
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
58 deletions
+40
-58
dp_backend.cxx
desktop/source/deployment/registry/dp_backend.cxx
+1
-1
tempfile.hxx
include/unotools/tempfile.hxx
+6
-5
tempfile.cxx
unotools/source/ucbhelper/tempfile.cxx
+33
-52
No files found.
desktop/source/deployment/registry/dp_backend.cxx
Dosyayı görüntüle @
a699927c
...
...
@@ -221,7 +221,7 @@ OUString PackageRegistryBackend::createFolder(
::
dp_misc
::
create_folder
(
&
dataContent
,
sDataFolder
,
xCmdEnv
);
const
OUString
baseDir
(
sDataFolder
);
const
::
utl
::
TempFile
aTemp
(
&
baseDir
,
true
);
::
utl
::
TempFile
aTemp
(
&
baseDir
,
true
);
const
OUString
url
=
aTemp
.
GetURL
();
return
sDataFolder
+
url
.
copy
(
url
.
lastIndexOf
(
'/'
));
}
...
...
include/unotools/tempfile.hxx
Dosyayı görüntüle @
a699927c
...
...
@@ -26,8 +26,6 @@
namespace
utl
{
struct
TempFile_Impl
;
/**
The class TempFile gives access to temporary files in the local file system. Sometimes they are needed because a 3rd party
code has a file name based interface, or some file access has to be done locally without transferring tons of bytes to or
...
...
@@ -46,8 +44,11 @@ struct TempFile_Impl;
class
UNOTOOLS_DLLPUBLIC
TempFile
{
TempFile_Impl
*
pImp
;
bool
bKillingFileEnabled
;
OUString
aName
;
OUString
aURL
;
SvStream
*
pStream
;
bool
bIsDirectory
;
bool
bKillingFileEnabled
;
// prevent copy c'tor
TempFile
(
const
TempFile
&
);
...
...
@@ -99,7 +100,7 @@ public:
If no UCP is available for the local file system, an empty URL is returned. In this case you can't access
the file as a UCB content !
*/
OUString
GetURL
()
const
;
OUString
GetURL
();
/**
Returns the "physical" name of the tempfile in host notation ( should only be used for 3rd party code
...
...
unotools/source/ucbhelper/tempfile.cxx
Dosyayı görüntüle @
a699927c
...
...
@@ -47,20 +47,6 @@ namespace
namespace
utl
{
struct
TempFile_Impl
{
OUString
aName
;
OUString
aURL
;
SvStream
*
pStream
;
bool
bIsDirectory
;
TempFile_Impl
()
:
pStream
(
0
)
,
bIsDirectory
(
false
)
{
}
};
OUString
getParentName
(
const
OUString
&
aFileName
)
{
sal_Int32
lastIndex
=
aFileName
.
lastIndexOf
(
'/'
);
...
...
@@ -249,11 +235,9 @@ void CreateTempName_Impl( OUString& rName, bool bKeep, bool bDir = true )
}
}
void
lcl_createName
(
TempFile_Impl
&
_rImpl
,
const
OUString
&
rLeadingChars
,
bool
_bStartWithZero
,
OUString
lcl_createName
(
const
OUString
&
rLeadingChars
,
bool
_bStartWithZero
,
const
OUString
*
pExtension
,
const
OUString
*
pParent
,
bool
bDirectory
)
{
_rImpl
.
bIsDirectory
=
bDirectory
;
// get correct directory
OUString
aName
=
ConstructTempDir_Impl
(
pParent
);
...
...
@@ -275,12 +259,11 @@ void lcl_createName(TempFile_Impl& _rImpl,const OUString& rLeadingChars, bool _b
FileBase
::
RC
err
=
Directory
::
create
(
aTmp
);
if
(
err
==
FileBase
::
E_None
)
{
_rImpl
.
aName
=
aTmp
;
break
;
return
aTmp
;
}
else
if
(
err
!=
FileBase
::
E_EXIST
)
// if f.e. name contains invalid chars stop trying to create dirs
break
;
return
OUString
()
;
}
else
{
...
...
@@ -295,9 +278,8 @@ void lcl_createName(TempFile_Impl& _rImpl,const OUString& rLeadingChars, bool _b
#endif
if
(
err
==
FileBase
::
E_None
||
err
==
FileBase
::
E_NOLCK
)
{
_rImpl
.
aName
=
aTmp
;
aFile
.
close
();
break
;
return
aTmp
;
}
else
if
(
err
!=
FileBase
::
E_EXIST
)
{
...
...
@@ -309,7 +291,7 @@ void lcl_createName(TempFile_Impl& _rImpl,const OUString& rLeadingChars, bool _b
if
(
DirectoryItem
::
get
(
aTmp
,
aTmpItem
)
!=
FileBase
::
E_None
||
aTmpItem
.
getFileStatus
(
aTmpStatus
)
!=
FileBase
::
E_None
||
aTmpStatus
.
getFileType
()
!=
FileStatus
::
Directory
)
break
;
return
OUString
()
;
}
}
if
(
!
_bStartWithZero
)
...
...
@@ -333,93 +315,92 @@ OUString TempFile::CreateTempName()
}
TempFile
::
TempFile
(
const
OUString
*
pParent
,
bool
bDirectory
)
:
pImp
(
new
TempFile_Impl
)
:
pStream
(
0
)
,
bIsDirectory
(
bDirectory
)
,
bKillingFileEnabled
(
false
)
{
pImp
->
bIsDirectory
=
bDirectory
;
// get correct directory
pImp
->
aName
=
ConstructTempDir_Impl
(
pParent
);
aName
=
ConstructTempDir_Impl
(
pParent
);
// get TempFile with default naming scheme
CreateTempName_Impl
(
pImp
->
aName
,
true
,
bDirectory
);
CreateTempName_Impl
(
aName
,
true
,
bDirectory
);
}
TempFile
::
TempFile
(
const
OUString
&
rLeadingChars
,
const
OUString
*
pExtension
,
const
OUString
*
pParent
,
bool
bDirectory
)
:
pImp
(
new
TempFile_Impl
)
:
pStream
(
0
)
,
bIsDirectory
(
bDirectory
)
,
bKillingFileEnabled
(
false
)
{
lcl_createName
(
*
pImp
,
rLeadingChars
,
true
,
pExtension
,
pParent
,
bDirectory
);
aName
=
lcl_createName
(
rLeadingChars
,
true
,
pExtension
,
pParent
,
bDirectory
);
}
TempFile
::
TempFile
(
const
OUString
&
rLeadingChars
,
bool
_bStartWithZero
,
const
OUString
*
pExtension
,
const
OUString
*
pParent
,
bool
bDirectory
)
:
pImp
(
new
TempFile_Impl
)
:
pStream
(
0
)
,
bIsDirectory
(
bDirectory
)
,
bKillingFileEnabled
(
false
)
{
lcl_createName
(
*
pImp
,
rLeadingChars
,
_bStartWithZero
,
pExtension
,
pParent
,
bDirectory
);
aName
=
lcl_createName
(
rLeadingChars
,
_bStartWithZero
,
pExtension
,
pParent
,
bDirectory
);
}
TempFile
::~
TempFile
()
{
delete
p
Imp
->
p
Stream
;
delete
pStream
;
if
(
bKillingFileEnabled
)
{
if
(
pImp
->
bIsDirectory
)
if
(
bIsDirectory
)
{
// at the moment no recursiv algorithm present
Directory
::
remove
(
pImp
->
aName
);
Directory
::
remove
(
aName
);
}
else
{
File
::
remove
(
pImp
->
aName
);
File
::
remove
(
aName
);
}
}
delete
pImp
;
}
bool
TempFile
::
IsValid
()
const
{
return
!
(
pImp
->
aName
.
isEmpty
()
);
return
!
aName
.
isEmpty
(
);
}
OUString
TempFile
::
GetFileName
()
const
{
OUString
aTmp
;
FileBase
::
getSystemPathFromFileURL
(
pImp
->
aName
,
aTmp
);
FileBase
::
getSystemPathFromFileURL
(
aName
,
aTmp
);
return
aTmp
;
}
OUString
TempFile
::
GetURL
()
const
OUString
TempFile
::
GetURL
()
{
if
(
pImp
->
aURL
.
isEmpty
()
)
if
(
aURL
.
isEmpty
()
)
{
OUString
aTmp
;
LocalFileHelper
::
ConvertPhysicalNameToURL
(
GetFileName
(),
aTmp
);
pImp
->
aURL
=
aTmp
;
aURL
=
aTmp
;
}
return
pImp
->
aURL
;
return
aURL
;
}
SvStream
*
TempFile
::
GetStream
(
StreamMode
eMode
)
{
if
(
!
p
Imp
->
p
Stream
)
if
(
!
pStream
)
{
if
(
!
GetURL
().
isEmpty
()
)
p
Imp
->
pStream
=
UcbStreamHelper
::
CreateStream
(
pImp
->
aURL
,
eMode
,
true
/* bFileExists */
);
p
Stream
=
UcbStreamHelper
::
CreateStream
(
aURL
,
eMode
,
true
/* bFileExists */
);
else
p
Imp
->
p
Stream
=
new
SvMemoryStream
(
eMode
);
pStream
=
new
SvMemoryStream
(
eMode
);
}
return
p
Imp
->
p
Stream
;
return
pStream
;
}
void
TempFile
::
CloseStream
()
{
if
(
p
Imp
->
p
Stream
)
if
(
pStream
)
{
delete
p
Imp
->
p
Stream
;
p
Imp
->
p
Stream
=
NULL
;
delete
pStream
;
pStream
=
NULL
;
}
}
...
...
@@ -456,7 +437,7 @@ OUString TempFile::SetTempNameBaseDirectory( const OUString &rBaseName )
TempFile
aBase
(
NULL
,
true
);
if
(
aBase
.
IsValid
()
)
// use it in case of success
rTempNameBase_Impl
=
aBase
.
pImp
->
aName
;
rTempNameBase_Impl
=
aBase
.
aName
;
// return system path of used directory
FileBase
::
getSystemPathFromFileURL
(
rTempNameBase_Impl
,
aTmp
);
...
...
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