Fix to save path containing filenames

Detect a . in the filePath and if we find one, save at root instead
(Stops us saving at a path that's actually a file, eg |TEST|file.txt)
This commit is contained in:
Matt Pass
2013-06-28 22:56:13 +01:00
parent c95772122f
commit cd38113da2
2 changed files with 51 additions and 48 deletions

View File

@@ -676,12 +676,15 @@ var ICEcoder = {
// Save a file
saveFile: function(saveAs) {
var saveType, filePath;
var saveType, filePath, pathPrefix;
saveType = saveAs ? "saveAs" : "save";
filePath = ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,"").replace(/\//g,"|");
if (filePath=="|[NEW]" && top.ICEcoder.selectedFiles.length>0) {
filePath = top.ICEcoder.selectedFiles[0]+filePath;
pathPrefix = top.ICEcoder.selectedFiles[0];
filePath = pathPrefix.lastIndexOf(".") == -1 || pathPrefix.lastIndexOf(".") < pathPrefix.lastIndexOf("|")
? pathPrefix+filePath
: "|[NEW]";
}
filePath = filePath.replace("||","|");
top.ICEcoder.serverQueue("add","lib/file-control.php?action=save&file="+filePath+"&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&saveType="+saveType);