1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-01-21 16:43:49 +00:00
parent 6b6411229f
commit 04752ec546
1376 changed files with 393460 additions and 412662 deletions

View File

@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <sys/stat.h>
#include <fcntl.h>
#include "SMFileFactory.h"
@ -25,83 +25,82 @@
using namespace std;
namespace idbdatafile {
IDBDataFile* SMFileFactory::open(const char *filename, const char *mode, unsigned opts, unsigned colWidth)
namespace idbdatafile
{
// TODO, test whether this breaks anything.
//if (opts & IDBDataFile::USE_TMPFILE)
// return new BufferedFile(filename, mode, opts);
bool _read = false;
bool _write = false;
bool create = false;
bool truncate = false;
bool append = false;
IDBDataFile* SMFileFactory::open(const char* filename, const char* mode, unsigned opts, unsigned colWidth)
{
// TODO, test whether this breaks anything.
// if (opts & IDBDataFile::USE_TMPFILE)
// return new BufferedFile(filename, mode, opts);
// strip 'b' chars from mode
char newmode[8] = {'\0'}; // there'd better not be 7 chars in the mode string
int i = 0;
for (const char *c = mode; *c != '\0' && i < 8; c++)
if (*c != 'b')
newmode[i++] = *c;
if (i == 8) {
errno = EINVAL;
return NULL;
}
// parse the new mode string
if (newmode[0] == 'r')
{
_read = true;
if (newmode[1] == '+')
_write = true;
}
else if (newmode[0] == 'w')
{
_write = true;
truncate = true;
create = true;
if (newmode[1] == '+')
_read = true;
}
else if (newmode[0] == 'a')
{
_write = true;
create = true;
append = true;
if (newmode[1] == '+')
_read = true;
}
else
{
errno = EINVAL;
return NULL;
}
// turn newmode into posix flags
uint posix_flags = 0;
if (_read && _write)
posix_flags |= O_RDWR;
else if (_read)
posix_flags |= O_RDONLY;
else if (_write)
posix_flags |= O_WRONLY;
posix_flags |= (create ? O_CREAT : 0);
posix_flags |= (truncate ? O_TRUNC : 0);
posix_flags |= (append ? O_APPEND : 0);
SMComm *comm = SMComm::get();
struct stat _stat;
int err = comm->open(filename, posix_flags, &_stat);
if (err)
return NULL;
SMDataFile *ret = new SMDataFile(filename, posix_flags, _stat);
return ret;
bool _read = false;
bool _write = false;
bool create = false;
bool truncate = false;
bool append = false;
// strip 'b' chars from mode
char newmode[8] = {'\0'}; // there'd better not be 7 chars in the mode string
int i = 0;
for (const char* c = mode; *c != '\0' && i < 8; c++)
if (*c != 'b')
newmode[i++] = *c;
if (i == 8)
{
errno = EINVAL;
return NULL;
}
// parse the new mode string
if (newmode[0] == 'r')
{
_read = true;
if (newmode[1] == '+')
_write = true;
}
else if (newmode[0] == 'w')
{
_write = true;
truncate = true;
create = true;
if (newmode[1] == '+')
_read = true;
}
else if (newmode[0] == 'a')
{
_write = true;
create = true;
append = true;
if (newmode[1] == '+')
_read = true;
}
else
{
errno = EINVAL;
return NULL;
}
// turn newmode into posix flags
uint posix_flags = 0;
if (_read && _write)
posix_flags |= O_RDWR;
else if (_read)
posix_flags |= O_RDONLY;
else if (_write)
posix_flags |= O_WRONLY;
posix_flags |= (create ? O_CREAT : 0);
posix_flags |= (truncate ? O_TRUNC : 0);
posix_flags |= (append ? O_APPEND : 0);
SMComm* comm = SMComm::get();
struct stat _stat;
int err = comm->open(filename, posix_flags, &_stat);
if (err)
return NULL;
SMDataFile* ret = new SMDataFile(filename, posix_flags, _stat);
return ret;
}
}
} // namespace idbdatafile