1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: loca_le.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "loca_le.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/loc/loc_dir.hxx>
37 #include <ary/loc/loc_file.hxx>
38 #include <ary/loc/loc_root.hxx>
39 #include <loc_internalgate.hxx>
40 #include "locs_le.hxx"
51 InternalGate::Create_Locations_()
53 return *new LocationAdmin
;
60 LocationAdmin::Storage() const
63 return *pStorage
.MutablePtr();
67 LocationAdmin::LocationAdmin()
68 : pStorage(new Le_Storage
)
72 LocationAdmin::~LocationAdmin()
77 LocationAdmin::CheckIn_Root(const csv::ploc::Path
& i_path
)
80 p_new( new Root(i_path
) );
83 id
= Storage().RootIndex().Search(p_new
->LocalName());
86 return ary_cast
<Root
>(Storage()[id
]);
91 Storage().Store_Entity(*p_new
.Release());
92 Storage().RootIndex().Add(ret
->LeId());
95 p_rootdir
= new Directory(ret
->LeId());
96 Storage().Store_Entity(*p_rootdir
);
97 ret
->Assign_Directory(p_rootdir
->LeId());
103 LocationAdmin::CheckIn_File( const String
& i_name
,
104 const csv::ploc::DirectoryChain
& i_subPath
,
108 root
= Find_Root(i_root
);
110 parent_dir
= CheckIn_Directories(
111 Find_Directory(root
.MyDir()),
115 fid
= parent_dir
.Search_File(i_name
);
116 if (NOT fid
.IsValid())
119 ret
= new File(i_name
, parent_dir
.LeId());
120 Storage().Store_Entity(*ret
);
121 parent_dir
.Add_File(*ret
);
126 return Find_File(fid
);
131 LocationAdmin::Find_Root(Le_id i_id
) const
133 return ary_cast
<Root
>(Storage()[i_id
]);
137 LocationAdmin::Find_Directory(Le_id i_id
) const
139 return ary_cast
<Directory
>(Storage()[i_id
]);
143 LocationAdmin::Find_File(Le_id i_id
) const
145 return ary_cast
<File
>(Storage()[i_id
]);
149 LocationAdmin::CheckIn_Directory( Directory
& io_parent
,
150 const String
& i_name
)
153 did
= io_parent
.Search_Dir(i_name
);
154 if (NOT did
.IsValid())
157 ret
= new Directory(i_name
, io_parent
.LeId());
158 Storage().Store_Entity(*ret
);
159 io_parent
.Add_Dir(*ret
);
164 return Find_Directory(did
);
169 LocationAdmin::CheckIn_Directories(
171 StringVector::const_iterator i_beginSubPath
,
172 StringVector::const_iterator i_endSubPath
)
174 if (i_beginSubPath
== i_endSubPath
)
178 next
= CheckIn_Directory(io_root
, *i_beginSubPath
);
179 return CheckIn_Directories(next
, i_beginSubPath
+1, i_endSubPath
);