Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2707161
dump.rs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
dump.rs
View Options
use
crate
::
file
::
Exists
;
use
crate
::
helpers
::{
self
,
Id
};
use
crate
::
process
::
Runner
;
use
colored
::
Colorize
;
use
global_placeholders
::
global
;
use
macros_rs
::{
crashln
,
string
};
use
std
::{
collections
::
BTreeMap
,
fs
};
pub
fn
read
()
->
Runner
{
if
!
Exists
::
folder
(
global
!
(
"pmc.base"
)).
unwrap
()
{
fs
::
create_dir_all
(
global
!
(
"pmc.base"
)).
unwrap
();
log
::
info
!
(
"created pmc base dir"
);
}
if
!
Exists
::
file
(
global
!
(
"pmc.dump"
)).
unwrap
()
{
let
runner
=
Runner
{
id
:
Id
::
new
(
0
),
log_path
:
global
!
(
"pmc.logs"
),
process_list
:
BTreeMap
::
new
(),
};
write
(
&
runner
);
log
::
info
!
(
"created dump file"
);
}
let
contents
=
match
fs
::
read_to_string
(
global
!
(
"pmc.dump"
))
{
Ok
(
contents
)
=>
contents
,
Err
(
err
)
=>
crashln
!
(
"{} Cannot find dumpfile.
\n
{}"
,
*
helpers
::
FAIL
,
string
!
(
err
).
white
()),
};
match
toml
::
from_str
(
&
contents
).
map_err
(
|
err
|
string
!
(
err
))
{
Ok
(
parsed
)
=>
parsed
,
Err
(
err
)
=>
crashln
!
(
"{} Cannot read dumpfile.
\n
{}"
,
*
helpers
::
FAIL
,
err
.
white
()),
}
}
pub
fn
write
(
dump
:
&
Runner
)
{
if
!
Exists
::
folder
(
global
!
(
"pmc.base"
)).
unwrap
()
{
fs
::
create_dir_all
(
global
!
(
"pmc.base"
)).
unwrap
();
log
::
info
!
(
"created pmc base dir"
);
}
let
contents
=
match
toml
::
to_string
(
dump
)
{
Ok
(
contents
)
=>
contents
,
Err
(
err
)
=>
crashln
!
(
"{} Cannot parse dump.
\n
{}"
,
*
helpers
::
FAIL
,
string
!
(
err
).
white
()),
};
if
let
Err
(
err
)
=
fs
::
write
(
global
!
(
"pmc.dump"
),
contents
)
{
crashln
!
(
"{} Error writing dumpfile.
\n
{}"
,
*
helpers
::
FAIL
,
string
!
(
err
).
white
())
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 1, 1:49 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
492736
Default Alt Text
dump.rs (1 KB)
Attached To
Mode
rPMC Process Management Controller
Attached
Detach File
Event Timeline
Log In to Comment