Using standard libraries to get temp path and to do file operations.
This makes the program more simple and safer because standard libraries clean the path and no need to use outside commands.
It also makes the code more portable since not all systems use '/tmp' as its tempfile path (other places for example, '/data/local/tmp'). Many mordern Linux distros also support setting the env varibale '$TMPDIR' to change a program's tempfile path. So using the standard library's getTempDir function is a better idea, it's done all the works for us.
Using standard libraries to get temp path and to do file operations.
This makes the program more simple and safer because standard libraries clean the path and no need to use outside commands.
It also makes the code more portable since not all systems use '/tmp' as its tempfile path (other places for example, '/data/local/tmp'). Many mordern Linux distros also support setting the env varibale '$TMPDIR' to change a program's tempfile path. So using the standard library's getTempDir function is a better idea, it's done all the works for us.