E-MailRelay

gfilestore_win32.cpp
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gfilestore_win32.cpp
19///
20
21#include "gdef.h"
22#include "gfilestore.h"
23#include "gpath.h"
24#include "genvironment.h"
25#include <cstdio>
26#include <crtdbg.h>
27
28 namespace GStore
29{
30 namespace FileStoreImp
31 {
32 struct NoCheck
33 {
34 NoCheck() ;
35 ~NoCheck() ;
36 NoCheck( const NoCheck & ) = delete ;
37 NoCheck( NoCheck && ) = delete ;
38 NoCheck & operator=( const NoCheck & ) = delete ;
39 NoCheck & operator=( NoCheck && ) = delete ;
40 _invalid_parameter_handler m_handler ;
41 int m_mode ;
42 static void handler( const wchar_t * , const wchar_t * , const wchar_t * , unsigned int , uintptr_t ) ;
43 } ;
44 }
45}
46
47 G::Path GStore::FileStore::defaultDirectory()
48{
49 return G::Path(G::Environment::get("ProgramData","c:/ProgramData"))/"E-MailRelay"/"spool" ;
50}
51
52 void GStore::FileStore::osinit()
53{
54 constexpr int limit = 8192 ;
55 if( _getmaxstdio() < limit )
56 {
57 FileStoreImp::NoCheck no_check ;
58 _setmaxstdio( limit ) ;
59 }
60}
61
62GStore::FileStoreImp::NoCheck::NoCheck() :
63 m_handler(_set_invalid_parameter_handler(NoCheck::handler)) ,
64 m_mode(_CrtSetReportMode(_CRT_ASSERT,0))
65{
66}
67
68GStore::FileStoreImp::NoCheck::~NoCheck()
69{
70 _set_invalid_parameter_handler( m_handler ) ;
71 _CrtSetReportMode( _CRT_ASSERT , m_mode ) ;
72}
73
74 void GStore::FileStoreImp::NoCheck::handler( const wchar_t * , const wchar_t * , const wchar_t * , unsigned int , uintptr_t )
75{
76 // no-op
77}
78
GStore::FileStore::defaultDirectory
static G::Path defaultDirectory()
Returns a default spool directory, such as "/var/spool/emailrelay".
Definition: gfilestore_unix.cpp:30
G::Environment::get
static std::string get(const std::string &name, const std::string &default_)
Returns the environment variable value or the given default.
Definition: genvironment_unix.cpp:35
G::Path
A Path object represents a file system path.
Definition: gpath.h:82
genvironment.h
gfilestore.h
gpath.h
GStore
Message store classes.
Definition: genvelope.cpp:30