1
Fork 0
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:
Andreas Kling 2018-10-10 11:53:07 +02:00
commit 5a30055157
67 changed files with 8836 additions and 0 deletions

33
AK/TemporaryFile.cpp Normal file
View 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);
}
}