Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Fixes:
Add 64 bit soundfont support (#211)
Skip randomly generated project name if a directory with that name already exists (#175)
Save Song As" saves to current as well as new project (#212)

1.5.0-bacon3
Contributions:
Expand Down
10 changes: 5 additions & 5 deletions sources/Application/Persistency/PersistencyService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
PersistencyService::PersistencyService():Service(MAKE_FOURCC('S','V','P','S')) {
} ;

void PersistencyService::Save() {
void PersistencyService::Save(const char *name) {

Path filename("project:lgptsav.dat") ;
Path filename(name);

TiXmlDocument doc(filename.GetPath()) ;
TiXmlElement first("LITTLEGPTRACKER") ;
TiXmlDocument doc(filename.GetPath());
TiXmlElement first("LITTLEGPTRACKER") ;
TiXmlNode *node=doc.InsertEndChild(first) ;

// Loop on all registered service
Expand All @@ -25,7 +25,7 @@ void PersistencyService::Save() {
} ;

doc.SaveFile() ;
} ;
};

bool PersistencyService::Load() {

Expand Down
4 changes: 2 additions & 2 deletions sources/Application/Persistency/PersistencyService.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
class PersistencyService: public Service,public T_Singleton<PersistencyService> {
public:
PersistencyService() ;
void Save() ;
bool Load() ;
void Save(const char *name = "project:lgptsav.dat");
bool Load() ;
} ;

class PersistencyDocument: public TiXmlDocument {
Expand Down
2 changes: 1 addition & 1 deletion sources/Application/Views/ModalDialogs/NewProjectDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class NewProjectDialog:public ModalView {
public:
NewProjectDialog(View &view, Path currentPath = "");
NewProjectDialog(View &view, Path currentPath = "root:");
virtual ~NewProjectDialog();

virtual void DrawView();
Expand Down
17 changes: 10 additions & 7 deletions sources/Application/Views/ProjectView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ static void SaveAsProjectCallback(View &v,ModalView &dialog) {
Path path_dstprjdir = Path(str_dstprjdir);
Path path_dstsmpdir = Path(str_dstsmpdir);

Path path_srclgptdatsav = path_srcprjdir.GetPath() + "lgptsav.dat";
Path path_dstlgptdatsav = path_dstprjdir.GetPath() + "/lgptsav.dat";
Path path_srclgptdatsav = path_srcprjdir.GetPath() + "lgptsav_tmp.dat";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see this is similar to what was there previously, but are we good with the inconsistency between the two filenames (i.e. one is prefixed with /, the other isn't)?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is required as the srcprj variable is fetched using project: which returns a trailing front slash :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for clarifying :)

Path path_dstlgptdatsav = path_dstprjdir.GetPath() + "/lgptsav.dat";

if (path_dstprjdir.Exists()) {
Trace::Log("ProjectView", "Dst Dir '%s' Exist == true",
Expand All @@ -55,10 +55,13 @@ static void SaveAsProjectCallback(View &v,ModalView &dialog) {
return;
};

FSS.Copy(path_srclgptdatsav,path_dstlgptdatsav);
if (FSS.Copy(path_srclgptdatsav, path_dstlgptdatsav) > -1) {
FSS.Delete(path_srclgptdatsav);
}

I_Dir *idir_srcsmpdir=FileSystem::GetInstance()->Open(path_srcsmpdir.GetPath().c_str());
if (idir_srcsmpdir) {
I_Dir *idir_srcsmpdir =
FileSystem::GetInstance()->Open(path_srcsmpdir.GetPath().c_str());
if (idir_srcsmpdir) {
idir_srcsmpdir->GetContent("*");
idir_srcsmpdir->Sort();
IteratorPtr<Path>it(idir_srcsmpdir->GetIterator());
Expand Down Expand Up @@ -270,8 +273,8 @@ void ProjectView::Update(Observable &,I_ObservableData *data) {
}
case ACTION_SAVE_AS: {
PersistencyService *service = PersistencyService::GetInstance();
service->Save();
NewProjectDialog *mb = new NewProjectDialog(*this);
service->Save("project:lgptsav_tmp.dat");
NewProjectDialog *mb = new NewProjectDialog(*this, "root:");
DoModal(mb, SaveAsProjectCallback);
break;
}
Expand Down
21 changes: 18 additions & 3 deletions sources/System/FileSystem/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ std::string Path::GetCanonicalPath() {
Path Path::Descend(const std::string& leaf)
{
std::string currentPath = GetPath();
if (currentPath[currentPath.size()-1] != '/')
{
currentPath += "/";
if (!currentPath.empty() && currentPath[currentPath.size() - 1] != '/') {
currentPath += "/";
}
return Path(currentPath+leaf);
}
Expand Down Expand Up @@ -215,4 +214,20 @@ int FileSystemService::Copy(const Path &src,const Path &dst)
isrc->Close();
idst->Close();
return nbwrite;
}

int FileSystemService::Delete(const Path &path) {
int result = -1;
std::string pathString = path.GetPath();
FileSystem * fs = FileSystem::GetInstance();

if (fs->GetFileType(pathString.c_str()) != FT_UNKNOWN) {
fs->Delete(pathString.c_str());
result += 1;
Trace::Log("FileSystemService"," Delete %s ", pathString.c_str());
} else {
Trace::Log("FS Delete","path does not exist: %s", pathString.c_str());
}

return result;
}
1 change: 1 addition & 0 deletions sources/System/FileSystem/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class FileSystem: public T_Factory<FileSystem> {
class FileSystemService {
public:
int Copy(const Path &src,const Path &dst);
int Delete(const Path &path);
};

#endif