Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Source Safe / February 2007

Tip: Looking for answers? Try searching our database.

VSS TypeLib and checking if a file exists (Delphi)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mr.Clean - 22 Jan 2007 17:15 GMT
I imported the Microsoft SourceSafe 8.0 Type Library and am having
problems determining if the file I'm trying to add already exists in the
VSS project. No satisfactory help in the Delphi TA so I thought I'd post
here to see if any VSS people may know the answer to the problem.

I get "Unspecified error" when trying to do this:

{VSSIniFile and VSSItemPath are consts}

procedure TfrmMain.VSSCheckin(AFileName, AVSSUserName,
                             AVSSPassword: String;
                             ACheckinIfDiff: Boolean;
                             ACheckInComment: String;
                             AExclusive: Boolean = True);
var
 oVSSItemPath: IVSSItem;
 oVSSItem:     IVSSItem;
 oVSSItems:    IVSSItems;
 oVSSDatabase: IVSSDatabase;
 iFlags:       Integer;
begin
 if AExclusive then
   iFlags := VSSCHECKOUT_EXCLUSIVE
 else
   iFlags := VSSCHECKOUT_SHARED;
 // Create the Database object
 oVSSDatabase := CreateOleObject('SourceSafe') as IVSSDatabase;
 try
   oVSSDatabase.Open(VSSIniFile, AVSSUserName, AVSSPassword);
   oVSSItemPath  := oVSSDatabase.VSSItem[VSSItemPath, False];
   oVSSItems     := oVSSItemPath.Items[False];
   /*** Unspecified error happens on the line between these marks ***/
   oVSSItem      := oVSSItems.Item[AFileName];
   /*** Unspecified error happens on the line between these marks ***/
   if oVSSItem <> nil then
   begin
     // Check it out...
     oVSSItem.Checkout('Checked out by SQL Generator', AFileName,
                       iFlags);
     // If it is different, check it in...otherwise undo
     // the above checkout
     if (oVSSItem.IsDifferent[AFileName]) and (ACheckinIfDiff) then
     begin
       oVSSItem.Checkin(ACheckInComment, AFileName, iFlags);
     end
     else
     begin
       if oVSSItem.IsCheckedOut > 0 then
         oVSSItem.UndoCheckout
     end;
   end
   else
     oVSSItemPath.Add(AFileName, ACheckInComment, iFlags);
   oVSSDatabase.Close;
 finally
   oVSSDatabase := nil;
 end;
end;

Any ideas as to how to check if the file already exists in the project?
I'm currently enumerating the items to check if it is there but would
like a more "elegant" way to check.
Rudi Larno - 19 Feb 2007 12:56 GMT
Hi Mr Clean,

I use the 'exception handling' to fnd out if a file does not exist and check
the ErrorCode. Sure, not as clean as you would like perhaps, but effective.

       public VSSItem Get(string vssSpec, bool Delete)
       {
           if (!this.isOpen) throw new VssDataBaseNotOpenException();
           Debug.WriteLine("Getting: " + vssSpec);
           Debug.Indent();
           try
           {
               return vssDb.get_VSSItem(vssSpec, false);
           }
           catch (System.Runtime.InteropServices.COMException comEx)
           {
               uint FileNotFound = 0x8004D68F;
               if (comEx.ErrorCode == (int)FileNotFound)
               {
                   Debug.WriteLine("=> does not exist in VSS");
                   Debug.Unindent();
                   return null;
               }
               else
               {
                   Debug.WriteLine("COM Exception ERROR: " + vssSpec);
                   Debug.WriteLine(comEx);
                   Debug.Unindent();
                   // raise Info event
                   return null;
               }
           }
           catch (Exception ex)
           {
               Debug.WriteLine("ERROR: " + vssSpec);
               Debug.WriteLine(ex);
               Debug.Unindent();
               // raise Info event
               return null;
           }
           finally
           {
               Debug.Unindent();
           }
       }

>I imported the Microsoft SourceSafe 8.0 Type Library and am having
> problems determining if the file I'm trying to add already exists in the
[quoted text clipped - 58 lines]
> I'm currently enumerating the items to check if it is there but would
> like a more "elegant" way to check.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.