Mercurial > ~dholland > hg > ag > index.cgi
view anagram/support/file.cpp @ 6:607e3be6bad8
Adjust to the moving target called the C++ standard.
Apparently nowadays it's not allowed to define an explicit copy
constructor but not an assignment operator. Consequently, defining the
explicit copy constructor in terms of the implicit/automatic
assignment operator for general convenience no longer works.
Add assignment operators.
Caution: not tested with the IBM compiler, but there's no particular
reason it shouldn't work.
author | David A. Holland |
---|---|
date | Mon, 30 May 2022 23:46:22 -0400 |
parents | 13d2b8934445 |
children |
line wrap: on
line source
/* * AnaGram, A System for Syntax Directed Programming * Copyright 1993-1999 Parsifal Software. All Rights Reserved. * Copyright 2006 David A. Holland. All Rights Reserved. * See the file COPYING for license and usage terms. * * file.cpp */ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <limits.h> #ifdef AG_ON_WINDOWS #include <direct.h> #include <share.h> #endif #ifdef AG_ON_UNIX #define SH_DENYNO 0 #define SH_DENYWR 0 #endif #include "port.h" #include "agstring.h" #include "file.h" //#define INCLUDE_LOGGING #include "log.h" AgString work_dir_name; //////////////////////////////////////////////////////////// /* * Open files, compatibly with DOS file sharing. * (Does this even mean anything in win32?) */ static int open_shared(const char *path, int openflags, int sharingmode) { int fd; LOGSECTION("open_shared"); LOGV(path); #ifdef AG_ON_UNIX /* * Unix filehandles are always shared, like it or not. We could * conceivably use mandatory locking for the denywrite case... but * (1) mandatory locking isn't universally supported, (2) it'll * likely cause permission problems, and (3) there's really not a * whole lot of point. */ (void)sharingmode; fd = open(path, openflags, 0664 /* default mode */); #endif #ifdef AG_ON_WINDOWS fd = sopen(path, openflags, sharingmode); #endif LOGV(fd); if (fd < 0) { LOGV(strerror(errno)); } return fd; } int open_shared_denywrite(const char *path, int openflags) { LOGSECTION("open_shared_denywrite"); return open_shared(path, openflags, SH_DENYWR); } int open_shared_any(const char *path, int openflags) { LOGSECTION("open_shared_any"); return open_shared(path, openflags, SH_DENYNO); } //////////////////////////////////////////////////////////// time_t getFileTimestamp(const char *name) { struct stat statbuf; stat(name, &statbuf); return statbuf.st_mtime; } //////////////////////////////////////////////////////////// void set_work_dir(void) { LOGSECTION("set_work_dir"); // in unix, this only needs to be PATH_MAX, but who knows about windows... char temp[PATH_MAX+1]; getcwd(temp, PATH_MAX); work_dir_name = AgString(temp); LOGV(work_dir_name); }