xref: /haiku/src/servers/launch/InitTemporaryDirectoryJob.cpp (revision 909af08f4328301fbdef1ffb41f566c3b5bec0c7)
1 /*
2  * Copyright 2015, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 //! Empty main temporary directory
8 
9 
10 #include "InitTemporaryDirectoryJob.h"
11 
12 #include <FindDirectory.h>
13 #include <Path.h>
14 
15 
16 InitTemporaryDirectoryJob::InitTemporaryDirectoryJob()
17 	:
18 	AbstractEmptyDirectoryJob("init /tmp")
19 {
20 }
21 
22 
23 status_t
24 InitTemporaryDirectoryJob::Execute()
25 {
26 	// TODO: the /tmp entries could be scanned synchronously, and deleted
27 	// later
28 	BPath path;
29 	status_t status = find_directory(B_SYSTEM_TEMP_DIRECTORY, &path, true);
30 	if (status == B_OK)
31 		status = CreateAndEmpty(path.Path());
32 
33 	chmod(path.Path(), 0777);
34 	return status;
35 }
36