delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/09/21/17:03:32

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:references
:in-reply-to:content-type:content-id:content-transfer-encoding
:mime-version; q=dns; s=default; b=irXTyOtYc03tZy8RVvHiWrG/HWnBv
J0m6DCPABDbqrMNqG4Lh9WRBMfsMuZQ+aNSQr/L6g0Xy4lnhTlRuVVGRmu+jqmtM
h7abXgZQgqQ4LGc9RKTdNklyjgyoHlapBrKpjcde/V5NWceOD11P5NKyGEKmgLEd
C5WZR8q2Pma/44=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:references
:in-reply-to:content-type:content-id:content-transfer-encoding
:mime-version; s=default; bh=y6qOz5D88xERZb3jvL2l1edgA9M=; b=Lga
z87ANaGEfQ+SnalEMacTrEzNTY9nGjfl05QVIFwQxNYIFKZdb6sw3pkuXEQ9BKUN
wCtP/wtVrtgjZ0lryAZl0A3/9qRTZpo3DeH2Sd/5fPG4+QMdkRml80uYLP3cJbrF
eyYWaXlkyZpiyEg88hX+ue2wXFdd66/zlUN7Y/Ds=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=
X-HELO: NAM05-BY2-obe.outbound.protection.outlook.com
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJR/ahW5S7WurVWZs1yB7mI0ExhDXwA7JA4z3kbeBZlEbqDA6Zk6rLMA6vHQHdPPTusS8GeatvgbwslefmKinsZsReJvxP1fxEupKm+mQ1nacMdR6d9NnsQgt6g114oF9IW6R1IKNzoKUrN/697L5xzOCqo1iSqDW31AYkf17GUzIFPrDQn3PEW6i4Ghvrt+GmlCPlrDI8YxKhZOQrM5T8jLRnrxdBEI/i+xUNX9rNv3snsNUcCu4QHfxEVu+nSuZ2EtigGLIs9dC6xG7mCkfwIhyYqokrxNfhyKHtdRGf+GkcyPZkurfMC3Y85yTWq1oWBjdv7nIx/TUFpC6/A0BQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yHBDGhNo9B4MLI1NTB4Q7Dnl/fBS2IJ2Zvvk0klXGI4=; b=O8Jk3pDb3ZagOc9p402v53i1TWq1NJLp/srcwcLHYfMzzPE/ZROpFTiEZSupEZNWD0jndS+tSFGnEcoFtymHxrJ29hbX3lIc/PWFKsDW7+H1vqoEhkVarNqX+xhEvbcQ4r/Lk8NGpRjAP2dp1sRoaUd9CiYC4wTVdPUy9DDxPQOJDGGCMSZZwAGuFPPLxLss+UA/gfvzKgwOMn4/o0EQw2V7kq3dcA6aARyPFp2MZaVtZrqeBDPk1G8OA640ocRhDiseoZqRVGhDNmRBZyEAFUDLsTy/yqCqX/zaMwDeYYWPcHZUdnBnJ2S0+IRrf/nJ3hK0Y2MXjz+pZJAtiDRN5w==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yHBDGhNo9B4MLI1NTB4Q7Dnl/fBS2IJ2Zvvk0klXGI4=; b=Ri3tpwFyTKVIDZJSmkSATbo/22Rkc3r3LJIb+hWLN7NhuVK+Lbu+ZNiF+sYgSVDOV8ACEDp157GYNoWXJvIEsyH0CAKCYMFWLHWckviYvM4GsLaWLBfvFXd14s5QuDaavLTLhzuNt2+GNdZkUtxH0YC7TcStosLoOi5ZYNe3DRs=
From: Ken Brown <kbrown AT cornell DOT edu>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Re: Solved. Odd, is it not? mkdir 'e:\' cannot be undone by rmdir 'e:\' ...
Date: Sat, 21 Sep 2019 21:02:37 +0000
Message-ID: <18fad38d-8b50-959c-1b4c-4b3080bd8c62@cornell.edu>
References: <8e310c59702b57501ca2fd80edf19d2e AT smtp-cloud9 DOT xs4all DOT net>
In-Reply-To: <8e310c59702b57501ca2fd80edf19d2e@smtp-cloud9.xs4all.net>
user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0
authentication-results: spf=none (sender IP is ) smtp.mailfrom=kbrown AT cornell DOT edu;
x-ms-oob-tlc-oobclassifiers: OLM:7691;
received-spf: None (protection.outlook.com: cornell.edu does not designate permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-ms-exchange-transport-forked: True
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: XE4HMJCmfhMfovTybNn0pDfsan+N/2boAyRtotZnEAEw0iEVN3R2rnAnwUSF1wEnkifZKxrCeOxSOAiLR37/Hw==
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id x8LL3EEP016832

On 9/6/2019 5:53 PM, Houder wrote:
> However an exception can be made for e:/ (or e:\), as follows:
> 
> --
>        char flag = '\0';
>        // strip trailing dirsep's, while remembering the last one
>        if (isdirsep (dir[strlen (dir) - 1]))
>          {
>            flag = dir[strlen (dir) - 1];
>            /* This converts // to /, but since both give EEXIST, we're okay.  */
>            char *buf;
>            char *p = stpcpy (buf = tp.c_get (), dir) - 1;
>            dir = buf;
>            while (p > dir && isdirsep (*p))
>             {
>              flag = *p;
>              *p-- = '\0';
>             }
>          }
> 
>        // reattach dirsep in case of x: and flag != '\0'
>        if ( (strlen (dir) == 2)
>             && (dir[1] == ':')
>             && isalpha (dir[0]) && flag != '\0' )
>          {
>            char *buf = tp.c_get ();
>            buf[0] = dir[0];
>            buf[1] = ':';
>            buf[2] = flag;
>            buf[3] = '\0';
>            dir = buf;
>          }

I think you can simplify this by eliminating the second part and changing the 
first part to the following:

         char sep = dir[strlen (dir) - 1];
         if (isdirsep (sep)
           {
             /* This converts // to /, but since both give EEXIST, we're okay. */
             char *buf;
             char *p = stpcpy (buf = tp.c_get (), dir) - 1;
             dir = buf;
             while (p > dir && isdirsep (*p))
               *p-- = '\0';
             /* Reattach dirsep in case of "x:". */
             if (p == dir + 1 && *p == ':' && isalpha (dir[0]))
               p[1] = sep;
           }

Ken

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019