Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ( !file || typeof file !== "string" ) {
throw new InvalidArgumentError( `File is empty or not a string` );
}
const filePath = join( directory, file );
// in case of snippets
if ( file === SNIPPETS_FILENAME && !fs.existsSync( filePath ) ) {
log.warn( `Suite file ${filePath} not found.` );
return null;
}
try {
const text = await readFile( filePath, "utf8" );
return parseJson( text, filePath );
} catch ( e ) {
log.warn( `Renderer process: io.readSuite: ${ e }` );
throw new IoError( `Suite file ${filePath} cannot be open.
Please make sure that the file exists and that you have read permission for it` );
}
}
if (targetPath.startsWith(sqlUrlPrefix)) {
const urlPath = targetPath.slice(sqlUrlPrefix.length)
const tableSepIndex = urlPath.lastIndexOf('/')
const tableName = urlPath.slice(tableSepIndex + 1)
const dbFileName = urlPath.slice(0, tableSepIndex)
rtc = await reltabSqlite.getContext(dbFileName, rtOptions)
ti = await rtc.getTableInfo(tableName)
} else {
rtc = await reltabSqlite.getContext(':memory:', rtOptions)
let pathname = targetPath
// check if pathname exists
if (!fs.existsSync(pathname)) {
let found = false
let srcdir = null
let srcDirTarget = null
log.warn('initMain: pathname not found: ', pathname)
const basename = path.basename(pathname)
if (srcfile) {
srcdir = path.dirname(srcfile)
srcDirTarget = path.join(srcdir, basename)
if (fs.existsSync(srcDirTarget)) {
log.warn('initMain: using ' + srcDirTarget + ' instead')
pathname = srcDirTarget
found = true
}
}
if (!found) {
let msg = '"' + pathname + '": file not found.'
if (srcdir) {
msg += '\n(Also tried "' + srcDirTarget + '")'
}
throw new Error(msg)
log.warn("Failed copy dolphin...");
log.warn(ex);
throw new Error(
"Failed to copy Dolphin instance on first boot. Try deleting the existing " +
"Dolphin instance in AppData and re-install. If that still doesn't work, please " +
"join the Slippi discord and ask for help in the #support-and-bugs channel"
);
}
if (shouldBkpUserDir) {
try {
log.info("Restoring backed up User directory...");
fs.moveSync(backupUserPath, targetUserPath, { overwrite: true });
} catch (ex) {
log.warn("Failed to restore user dir")
log.warn(ex);
}
}
log.info("Done copying Dolphin");
} else {
log.info("Install time matches, this is not a new install.");
}
}
// Add game path to Playback Dolphin
const isoPath = electronSettings.get("settings.isoPath");
if (isoPath){
log.info("ISO path found");
const fileDir = path.dirname(isoPath);
const storedDolphinPath = electronSettings.get('settings.playbackDolphinPath');
const handleOpen = (event, filePath) => {
log.log('handleOpen called!')
log.warn('got open-file event for: ', filePath)
event.preventDefault()
const targetPath = getTargetPath(options, filePath)
if (isReady) {
log.warn('open-file: app is ready, opening in new window')
appWindow.create(targetPath)
} else {
openFilePath = targetPath
log.warn('open-file: set openFilePath ' + targetPath)
}
}
public warn(msg: string, ...args: any[]) {
delegate.warn(msg, ...args);
}
FileObject.prototype.getObjectUrl = () => {
if (this.objectUrl !== '' && !this.disposed) {
return this.objectUrl;
}
if (!this.disposed) {
this.objectUrl = window.URL.createObjectURL(this.data);
return this.objectUrl;
}
log.warn('File disposed!');
throw 'File disposed!';
};
warning(...args) {
return log.warn(`[${this.moduleName}]`, ...args)
}
write(level: LogLevelType, message: string) {
if (this.filter != null && this.filter(level)) {
return;
}
switch (level) {
case LogLevelType.Debug:
log.debug(message);
break;
case LogLevelType.Info:
log.info(message);
break;
case LogLevelType.Warning:
log.warn(message);
break;
case LogLevelType.Error:
log.error(message);
break;
default:
break;
}
}
}
_handleDefaultAction(action) {
const rIndex = action.indexOf('renderer:');
if (rIndex === 0) {
const actionName = action.substr(9);
this._dispatchRendererAction(actionName);
return;
}
const mIndex = action.indexOf('main:');
if (mIndex === 0) {
const actionName = action.substr(5);
this._dispatchMainAction(actionName);
return;
}
log.warn('Unknown context menu action: ' + action);
}
/**