Aggiunte configureazioni per utente
git-svn-id: svn://10.65.10.50/trunk@1044 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									c0c5742d3a
								
							
						
					
					
						commit
						eb18a553fa
					
				@ -1,13 +1,13 @@
 | 
				
			|||||||
 | 
					#include <direct.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <xvt.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <applicat.h>
 | 
					#include <applicat.h>
 | 
				
			||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					#include <prefix.h>
 | 
				
			||||||
#include <utility.h>
 | 
					#include <utility.h>
 | 
				
			||||||
#include <scanner.h>
 | 
					#include <scanner.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HIDDEN const char * files[] = {"prassi.ini", "prassis.ini", 
 | 
					 | 
				
			||||||
                               "prassid.ini", "fconv.ini"};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C"
 | 
					extern "C"
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  int rename(const char*, const char*);
 | 
					  int rename(const char*, const char*);
 | 
				
			||||||
@ -262,20 +262,48 @@ void TConfig::init(const char *fn, const char* pa)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TConfig::TConfig(int which_config, const char* paragraph)
 | 
					TConfig::TConfig(int which_config, const char* paragraph)
 | 
				
			||||||
: _file(files[which_config])
 | 
					{             
 | 
				
			||||||
{
 | 
					  switch (which_config)
 | 
				
			||||||
  if (which_config == CONFIG_DITTA)
 | 
					 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    _file.insert(format("%s/", main_app().get_firm_dir()));
 | 
					  case CONFIG_DITTA:
 | 
				
			||||||
 | 
					    _file << main_app().get_firm_dir() << '/' << "prassid.ini";
 | 
				
			||||||
 | 
					    if (!fexist(_file)) fcopy("prassid.ini", _file);   
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case CONFIG_STUDIO:
 | 
				
			||||||
 | 
					    _file = "prassi.ini";
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case CONFIG_USER:
 | 
				
			||||||
 | 
					    _file = main_app().get_firm_dir();
 | 
				
			||||||
 | 
					    if (_file.not_empty())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      for (int i = _file.len()-1; i >= 0; i--)
 | 
				
			||||||
 | 
					        if (_file[i] == '/' || _file[i] == '\\') break;
 | 
				
			||||||
 | 
					      _file.cut(i+1);
 | 
				
			||||||
 | 
					    }  
 | 
				
			||||||
 | 
					    _file << "config";
 | 
				
			||||||
    if (!fexist(_file))
 | 
					    if (!fexist(_file))
 | 
				
			||||||
      fcopy(files[CONFIG_DITTA], _file);   
 | 
					    {
 | 
				
			||||||
  }
 | 
					#if XVT_OS==XVT_OS_SCOUNIX
 | 
				
			||||||
 | 
					      mkdir(_file, 0777);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					      mkdir(_file);
 | 
				
			||||||
 | 
					#endif       
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    _file << '/' << main_app().user() << ".ini";
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  default:
 | 
				
			||||||
 | 
					    _file = "prassi.ini";
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  }  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!fexist(_file))
 | 
					  if (!fexist(_file))
 | 
				
			||||||
    fatal_box("Impossibile aprire la configurazione %s", 
 | 
					  {
 | 
				
			||||||
              which_config == CONFIG_GENERAL ? "generale" :
 | 
					    FILE* c = fopen(_file, "w");
 | 
				
			||||||
              which_config == CONFIG_STUDIO ? "di studio" : 
 | 
					    CHECKS(c, "Impossibile aprire il file di configurazione %s", (const char*)_file);
 | 
				
			||||||
              which_config == CONFIG_DITTA ? "della ditta": "per la conversione archivi");
 | 
					    fclose(c);
 | 
				
			||||||
  init( _file, paragraph );
 | 
					  }  
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  init(_file, paragraph);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TConfig::TConfig(const char *fn, const char* pa) 
 | 
					TConfig::TConfig(const char *fn, const char* pa) 
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
#ifndef __CONFIG_H
 | 
					#ifndef __CONFIG_H
 | 
				
			||||||
#define __CONFIG_H 
 | 
					#define __CONFIG_H 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef XVT_INCL
 | 
					#ifndef INCL_XVTH
 | 
				
			||||||
#include <xvt.h>
 | 
					#include <xvt.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -9,10 +9,6 @@
 | 
				
			|||||||
#include <assoc.h>
 | 
					#include <assoc.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef __STRINGS_H
 | 
					 | 
				
			||||||
#include <strings.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class ofstream;
 | 
					class ofstream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// questo sara' il principale, per ora non c'e'
 | 
					// questo sara' il principale, per ora non c'e'
 | 
				
			||||||
@ -23,6 +19,8 @@ class ofstream;
 | 
				
			|||||||
#define CONFIG_DITTA    2
 | 
					#define CONFIG_DITTA    2
 | 
				
			||||||
// file conversioni archivi
 | 
					// file conversioni archivi
 | 
				
			||||||
#define CONFIG_FCONV    3
 | 
					#define CONFIG_FCONV    3
 | 
				
			||||||
 | 
					// file parametri utente
 | 
				
			||||||
 | 
					#define CONFIG_USER     4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TConfig : public TObject
 | 
					class TConfig : public TObject
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user