FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing-docs/generate/domit/php_file_utilities.php at master · processing/processing-docs · GitHub
processing
processing-docs
Repository navigation
Code
Issues
3
(3)
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing-docs
/
generate
/
domit
/
php_file_utilities.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (41 loc) · 1.25 KB
Breadcrumbs
processing-docs
/
generate
/
domit
/
php_file_utilities.php
Copy path
File metadata and controls
50 lines (41 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<?php
if
(!
defined
(
'
PHP_TEXT_CACHE_INCLUDE_PATH
'
)) {
define
(
'
PHP_TEXT_CACHE_INCLUDE_PATH
'
, (
dirname
(
__FILE__
) .
"
/
"
));
}
class
php_file_utilities {
/**
* Retrieves binary or text data from the specified file
* @param string The file path
* @param string The attributes for the read operation ('r' or 'rb' or 'rt')
* @return mixed he text or binary data contained in the file
*/
function
&
getDataFromFile
(
$
filename
,
$
readAttributes
,
$
readSize
=
8192
) {
$
fileContents
=
null
;
$
fileHandle
= @
fopen
(
$
filename
,
$
readAttributes
);
if
(
$
fileHandle
){
do
{
$
data
=
fread
(
$
fileHandle
,
$
readSize
);
if
(
strlen
(
$
data
) ==
0
) {
break
;
}
$
fileContents
.=
$
data
;
}
while
(
true
);
fclose
(
$
fileHandle
);
}
return
$
fileContents
;
}
//getDataFromFile
/**
* Writes the specified binary or text data to a file
* @param string The file path
* @param mixed The data to be written
* @param string The attributes for the write operation ('w' or 'wb')
*/
function
putDataToFile
(
$
fileName
, &
$
data
,
$
writeAttributes
) {
$
fileHandle
= @
fopen
(
$
fileName
,
$
writeAttributes
);
if
(
$
fileHandle
) {
fwrite
(
$
fileHandle
,
$
data
);
fclose
(
$
fileHandle
);
}
}
//putDataToFile
}
//php_file_utilities
?>
Back
|
FazBrowse Home
|
New Git URL