mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:47:35 +00:00
Import all this stuff into a single repo called Serenity.
This commit is contained in:
commit
5a30055157
67 changed files with 8836 additions and 0 deletions
33
AK/TemporaryFile.cpp
Normal file
33
AK/TemporaryFile.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "TemporaryFile.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
TemporaryFile::TemporaryFile()
|
||||
{
|
||||
char nameBuffer[] = "/tmp/AKTemporaryFile.XXXXXX";
|
||||
int fd = mkstemp(nameBuffer);
|
||||
if (fd != -1) {
|
||||
m_stream = fdopen(fd, "w+");
|
||||
m_fileName = nameBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
TemporaryFile::~TemporaryFile()
|
||||
{
|
||||
if (isValid()) {
|
||||
unlink(m_fileName.characters());
|
||||
fclose(m_stream);
|
||||
}
|
||||
}
|
||||
|
||||
void TemporaryFile::sync()
|
||||
{
|
||||
if (m_stream)
|
||||
fflush(m_stream);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue