Re: [BLACKBOX] Deleting a directory

From: [at]} <Robert>
Date: Thu, 9 Dec 2010 23:23:05 +0000

----boundary-LibPST-iamunique-238174445_-_-
Content-type: text/plain

Thanks Chris

I have just (this second!) had an apparently successful experiment;

   VAR
     res : INTEGER;
     name : ARRAY 40 OF CHAR;
   BEGIN
    res := Api.RemoveDirectoryW ('C:\BlackBox\Fred')

seems to work ok (provided \\Fred is empty etc),

as does

    name := 'C:\BlackBox\Fred';
    res := Api.RemoveDirectoryW (name);



Thanks

Robert



On 09/12/2010 11:01 PM, Chris Burrows wrote:
>> -----Original Message-----
>> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>> Sent: Friday, 10 December 2010 8:31 AM
>> To: BLACKBOX{([at]})nowhere.xy
>> Subject: [BLACKBOX] Deleting a directory
>>
>> Hi,
>>
>> I'm sure I've done this before, but have forgotten how (and where)!
>>
>>
>> To delete a File one calls
>>
>> Files.dir.Delete (loc, name$)
>>
>> but how do you delete a directory?
>>
>
> One way you can do it is with a direct call to the Windows API:
>
> PROCEDURE DeleteDir*(IN name: ARRAY OF CHAR): BOOLEAN;
> BEGIN
> RETURN WinApi.RemoveDirectory(WinStr(name)) # 0
> END DeleteDir;
>
> DeleteDir returns TRUE if the directory could be deleted (i.e. if it is
> empty, has delete permissions etc.)
>
> The tricky part is that the RemoveDirectory function requires a parameter of
> type WinApi.PtrSTR. The following function returns a WinApi.PtrSTR given an
> ARRAY OF CHAR. There might be a better way but it seems to work:
>
> PROCEDURE WinStr(IN x: ARRAY OF CHAR): WinApi.PtrSTR;
> VAR
> p: POINTER TO ARRAY OF SHORTCHAR;
> BEGIN
> NEW(p, LEN(x$) + 1);
> p^ := SHORT(x$);
> RETURN p^
> END WinStr;
>
> Regards,
> Chris
>
> Chris Burrows
> CFB Software
> http://www.cfbsoftware.com
>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1170 / Virus Database: 426/3305 - Release Date: 12/09/10
>
>


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-238174445_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFRoYW5rcyBDaHJpc1xwYXINClxwYXINCkkgaGF2
ZSBqdXN0ICh0aGlzIHNlY29uZCEpIGhhZCBhbiBhcHBhcmVudGx5IHN1Y2Nlc3NmdWwgZXhwZXJp
bWVudDtccGFyDQpccGFyDQogICBWQVJccGFyDQogICAgIHJlcyAgIDogIElOVEVHRVI7XHBhcg0K
ICAgICBuYW1lICA6ICBBUlJBWSAgNDAgIE9GICBDSEFSO1xwYXINCiAgIEJFR0lOXHBhcg0KICAg
IHJlcyAgOj0gIEFwaS5SZW1vdmVEaXJlY3RvcnlXICgnQzpcXEJsYWNrQm94XFxGcmVkJylccGFy
DQpccGFyDQpzZWVtcyB0byB3b3JrIG9rIChwcm92aWRlZCBcXFxcRnJlZCBpcyBlbXB0eSBldGMp
LFxwYXINClxwYXINCmFzIGRvZXNccGFyDQpccGFyDQogICAgbmFtZSAgOj0gICdDOlxcQmxhY2tC
b3hcXEZyZWQnO1xwYXINCiAgICByZXMgICA6PSAgQXBpLlJlbW92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zIEJ1cnJvd3NccGFyDQo+IENGQiBTb2Z0d2FyZVxwYXINCj4g
aHR0cDovL3d3dy5jZmJzb2Z0d2FyZS5jb21ccGFyDQo+XHBhcg0KPlxwYXINCj4gLS0tLVxwYXIN
Cj4gVG8gdW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFD
S0JPWCIgdG8gTElTVFNFUlZATElTVFMuT0JFUk9OLkNIXHBhcg0KPlxwYXINCj5ccGFyDQo+IC0t
LS0tXHBhcg0KPiBObyB2aXJ1cyBmb3VuZCBpbiB0aGlzIG1lc3NhZ2UuXHBhcg0KPiBDaGVja2Vk
IGJ5IEFWRyAtIHd3dy5hdmcuY29tXHBhcg0KPiBWZXJzaW9uOiAxMC4wLjExNzAgLyBWaXJ1cyBE
YXRhYmFzZTogNDI2LzMzMDUgLSBSZWxlYXNlIERhdGU6IDEyLzA5LzEwXHBhcg0KPlxwYXINCj5c
cGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdl
IHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNFUlZATElTVFMuT0JFUk9OLn19
AE9YLXVucw==
----boundary-LibPST-iamunique-238174445_-_---
Received on Fri Dec 10 2010 - 00:23:05 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:27 UTC