Asked  7 Months ago    Answers:  5   Viewed   19 times

Is there any way to check whether a file is locked without using a try/catch block?

Right now, the only way I know of is to just open the file and catch any System.IO.IOException.



No, unfortunately, and if you think about it, that information would be worthless anyway since the file could become locked the very next second (read: short timespan).

Why specifically do you need to know if the file is locked anyway? Knowing that might give us some other way of giving you good advice.

If your code would look like this:

if not locked then
    open and update file

Then between the two lines, another process could easily lock the file, giving you the same problem you were trying to avoid to begin with: exceptions.

Tuesday, June 1, 2021
answered 7 Months ago

Check out Pathname and in particular Pathname#exist?.

File and its FileTest module are perhaps simpler/more direct, but I find Pathname a nicer interface in general.

Tuesday, July 27, 2021
answered 5 Months ago

Apart from just checking out the folders you want (which only works if you want the entire subfolder tree as well), Subversion 1.7 supports something referred to as "sparse directories". Basically you can checkout a folder to a certain depth, and then afterwards "drill down" into the folders you are interested in.

Using the command line client, you use the --depth and --set-depth options to svn update. If you are using TortoiseSVN, there is a "Checkout Depth" option in the checkout dialog.

EDIT: To clarify against your specific question, you would first to a checkout of your source tree with depth "immediates". This will give you all your folders, but they will initially be empty. Then you can drill down in the Extensions and Themes directories by updating them to "fully recursive" depth (svn update --set-depth infinity or in TortoiseSVN "Update to revision → Update Depth → "Fully Recursive").

EDIT: The update depth can be seen as a sort of "visibility level", and is remembered by Subversion, i.e. if you do a svn update on your working copy, it will only update to the current visibility level.

Tuesday, August 3, 2021
answered 4 Months ago

Are you doing this at work? Is a corporate firewall or anti-virus program running? Check the windows event logs and any applications in your task notification icons area on your start bar for hints as to who is blocking this.

Wednesday, August 25, 2021
answered 4 Months ago

i just had the same problem. Installed the Conditioner pane on Lion and after updating to Mountain Lion, it still was available in the settings pane, but had no effect when turned on.

i fixed that by just removing the Conditioner (right click in the settings pane -> Remove "Network...") and reinstalling it from the Hardware IO Tools Image (Late July 2012).

Hope it works too for you. i think the os x update must have overwritten something.

Thursday, October 28, 2021
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :