home *** CD-ROM | disk | FTP | other *** search
- /**
- * Diese Klasse beinhaltet Methoden f├╝r das File-Handling
- *
- * @namespace IM
- * @class FileUtils
- * @constructor
- */
- IM.FileUtils = function () {
- /**
- * NodeJS: Setzt die gui-Lib aus der globalen Konfiguration
- * @property gui
- * @type Object
- * @private
- */
- var gui = IM.Config.gui,
-
- /**
- * NodeJS: Setzt die path-Lib aus der globalen Konfiguration
- * @property path
- * @type Object
- * @private
- */
- path = IM.Config.path,
-
- /**
- * NodeJS: Setzt die fs-Lib aus der globalen Konfiguration
- * @property fs
- * @type Object
- * @private
- */
- fs = IM.Config.fs;
-
- /**
- * Baut den Pfad zur Datei und wenn diese existiert wird ein Objekt mit entsprechenden Daten zur├╝ckgegeben.
- * @method _getFilePath
- * @param {String} file Der relative Pfad zur Datei
- * @private
- * @return {Object} Das Object beinhaltet 2 Variablen ( fileExists, filePath ).
- */
- var _getFilePath = function ( file ) {
- /**
- * Speichert und setzt den Pfad zur Datei
- * @property filePath
- * @type String
- * @private
- */
- var filePath = path.join( path.dirname( process.execPath ), file ),
-
- /**
- * Speichert und pr├╝ft die Existenz der jeweiligen Datei
- * @property fileExists
- * @type Boolean
- * @private
- */
- fileExists = fs.existsSync( filePath ),
-
- /**
- * Speichert den Wert des zur├╝ckgegebenen Wertes.
- * @property result
- * @type Object
- * @private
- */
- result = {
- fileExists: fileExists,
- filePath: filePath
- };
-
- return result;
- };
-
- /**
- * Öffnet eine Datei (file)
- * @method openFile
- * @param {String} file Der relative Pfad zur Datei
- */
- this.openFile = function ( file ) {
- /**
- * Speichert das Ergebnis der Methode _getFilePath
- * @property fileInfo
- * @type Object
- * @private
- */
- var fileInfo = _getFilePath( 'interface' + file );
-
- if( fileInfo.fileExists ) {
- gui.Shell.openItem( fileInfo.filePath );
- } else {
- IM.ErrorHandler.errorMsg( 'Datei "' + file + '" wurde nicht gefunden.', 'type' );
- }
- };
-
- /**
- * Öffnet den Ordner der Datei (file) im Dateibrowser
- * @method openFileDir
- * @param {String} file Der relative Pfad zur Datei
- */
- this.openFileDir = function ( file ) {
- var fileInfo = _getFilePath( 'interface' + file );
-
- if( fileInfo.fileExists ) {
- gui.Shell.showItemInFolder( fileInfo.filePath );
- } else {
- IM.ErrorHandler.errorMsg( 'Der Ordner konnte nicht ge├╢ffnet werden, da die Datei "' + file + '" nicht gefunden wurde.', 'type' );
- }
- };
-
- /**
- * Öffnet eine URL im Standardbrowser des Systems
- * @method openLink
- * @param {String} url Die zu ├╢ffnende URL
- */
- this.openLink = function ( url ) {
- gui.Shell.openExternal( url );
- };
- };