delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/07/30/15:33:23

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_YG
X-Spam-Check-By: sourceware.org
Message-ID: <4C5328F5.8010909@bopp.net>
Date: Fri, 30 Jul 2010 14:33:09 -0500
From: Jeremy Bopp <jeremy AT bopp DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Question on Java and Cygwin
References: <OF593E7D3D DOT EA2CD570-ON86257770 DOT 00673592-86257770 DOT 0067F72A AT ni DOT com> <4C5320F2 DOT 6020207 AT bopp DOT net> <OFB2177B85 DOT 286F742E-ON86257770 DOT 0069B6FC-86257770 DOT 0069DA2F AT ni DOT com>
In-Reply-To: <OFB2177B85.286F742E-ON86257770.0069B6FC-86257770.0069DA2F@ni.com>
X-IsSubscribed: yes
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

On 7/30/2010 2:16 PM, Ernest Mueller wrote:
> Am trying to use Java file.io without shelling out all the time.  To use
> cygpath you basically have to spawn shells to do any IO commands, which is
> not a best practice.

http://www.cygwin.com/acronyms/#PCYMTNQREAIYR :-)

With that out of the way, what exactly are you trying to do?  Are you
trying to open files whose paths are POSIX paths, or are you trying to
create paths which you need to hand off to Cygwin processes?  Another
way of phrasing this is: is your program being called *from* Cygwin or
is it trying to call *into* Cygwin?  In the former case, those POSIX
paths can be converted by whatever is calling your Java program prior to
handing off the paths.  There would be no extra shell-out for that in
most cases.  In the latter case, you are already shelling out to call
the Cygwin process, so you can integrate the call there to avoid an
extra shell-out.

The problem you're facing is common for Windows applications (of which
Java applications are members) integrating with Cygwin applications.
The "ant" script shipped with Apache Ant has some good examples of how
to ensure that POSIX paths are handed off to Java correctly.  I can't
think of a good example offhand for calling into Cygwin, but you can
often handle that most simply by creating a script to use as a shim for
converting your paths prior which then goes on to call the script or
program you really need to run.

If there is still confusion, perhaps you could include a short snippet
of code which demonstrates what you want to do.

-Jeremy

--
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