1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
file.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Translate\IO;
4
5
use Bitrix\Translate;
6
use Bitrix\Main;
7
8
9
class
File
extends
Main\IO\File
implements
Translate\IErrorable
10
{
11
// trait implements interface Translate\IErrorable
12
use
Translate\Error
;
13
23
public
static
function
generateTemporalFile
(
string
$prefix,
string
$suffix =
'.tmp'
,
int
$timeToLive = 3): self
24
{
25
$tempDir = \CTempFile::getDirectoryName($timeToLive,
array
($prefix, \uniqid($prefix,
true
)));
26
Path::checkCreatePath
($tempDir.
'/'
);
27
28
$hash
= \str_pad(\dechex(\crc32($tempDir)), 8,
'0'
, STR_PAD_LEFT);
29
$fileName
= \uniqid(
$hash
.
'_'
,
false
). $suffix;
30
31
return
new
static
($tempDir.
$fileName
);
32
}
33
39
public
function
openLoad
(): bool
40
{
41
if
($this->
isExists
())
42
{
43
$this->
open
(
Main
\
IO
\FileStreamOpenMode::READ);
44
}
45
46
return
$this->
isExists
() && $this->
isReadable
();
47
}
48
54
public
function
openWrite
(): bool
55
{
56
$this->
open
(
Main
\
IO
\FileStreamOpenMode::WRITE);
57
58
return
$this->
isWritable
();
59
}
60
61
69
public
function
read
(
int
$length): string
70
{
71
if
(\feof($this->filePointer))
72
{
73
return
''
;
74
}
75
76
return \fread($this->filePointer, $length);
77
}
78
88
public
function
write
(
string
$content
): int
89
{
90
if
(!\is_resource($this->filePointer))
91
{
92
throw
new
Main\IO\FileNotOpenedException
($this->
getPath
());
93
}
94
95
$length = \fwrite($this->filePointer,
$content
);
96
if
($length ===
false
)
97
{
98
throw
new
Main\IO\IoException
(
"Cannot write file"
);
99
}
100
101
return
$length;
102
}
103
110
public
function
close
(): void
111
{
112
if
(!\is_resource($this->filePointer))
113
{
114
@\fflush($this->filePointer);
115
}
116
117
parent::close();
118
119
@clearstatcache(
true
, $this->
getPhysicalPath
());
120
}
121
}
$hash
$hash
Определения
ajax_redirector.php:8
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\IO\File\open
open($mode)
Определения
file.php:25
Bitrix\Main\IO\File\isReadable
isReadable()
Определения
file.php:194
Bitrix\Main\IO\File\isWritable
isWritable()
Определения
file.php:184
Bitrix\Main\IO\File\isExists
isExists()
Определения
file.php:50
Bitrix\Main\IO\FileNotOpenedException
Определения
filenotopenedexception.php:6
Bitrix\Main\IO\FileSystemEntry\getPath
getPath()
Определения
filesystementry.php:80
Bitrix\Main\IO\FileSystemEntry\getPhysicalPath
getPhysicalPath()
Определения
filesystementry.php:142
Bitrix\Main\IO\IoException
Определения
ioexception.php:9
Bitrix\Translate\IO\File\read
read(int $length)
Определения
file.php:69
Bitrix\Translate\IO\File\generateTemporalFile
static generateTemporalFile(string $prefix, string $suffix='.tmp', int $timeToLive=3)
Определения
file.php:23
Bitrix\Translate\IO\File\write
write(string $content)
Определения
file.php:88
Bitrix\Translate\IO\File\close
close()
Определения
file.php:110
Bitrix\Translate\IO\File\openLoad
openLoad()
Определения
file.php:39
Bitrix\Translate\IO\File\openWrite
openWrite()
Определения
file.php:54
Bitrix\Translate\IO\Path\checkCreatePath
static checkCreatePath(string $path)
Определения
path.php:180
$content
$content
Определения
commerceml.php:144
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Translate\IErrorable
Определения
ierrorable.php:8
Bitrix\Main\File
Определения
Image.php:9
Bitrix\Main\IO
Определения
directory.php:3
Bitrix\Main
$fileName
$fileName
Определения
quickway.php:305
bitrix
modules
translate
lib
io
file.php
Создано системой
1.14.0