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