exists

How expensive is File.exists in Java

匿名 (未验证) 提交于 2019-12-03 01:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am wondering how File.exists() works. I'm not very aware of how filesystems work, so I should maybe start reading there first. But for a quick pre information: Is a call to File.exists() a single action for the filesystem, if that path and filename are registered in some journal? Or does the OS get the content of the directory and then scan through it for matches? I presume this will be filesystem dependant, but maybe all filesystems use the quick approach? I'm not talking about network and tape systems. Lets keep it to ntfs, extX, zfs,

Check if file exists on remote machine

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to check if a file exists on a remote webserver with php. I now have this function: function url_exists ( $url ) { // Version 4.x supported $handle = curl_init ( $url ); if ( false === $handle ) { return false ; } curl_setopt ( $handle , CURLOPT_HEADER , false ); curl_setopt ( $handle , CURLOPT_FAILONERROR , true ); // this works curl_setopt ( $handle , CURLOPT_HTTPHEADER , Array ( "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15" ) ); // request as if Firefox curl

postmaster dead but pid file exists

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We have a rails 4 application with postgres Sometimes our server hanged and if we reboot it . The server gets started but it can not connect to postgres. status shows postmaster dead but pid file exists log shows FATAL: lock file "/tmp/.s.PGSQL.5432.lock" already exists HINT: Is another postmaster (PID 4696) using socket file "/tmp/.s.PGSQL.5432"? LOG: could not bind IPv4 socket: Address already in use and the postgresql could not restarted. --- After deleting the /tmp/.s.PGSQL.5432 file and restarting the postgres service the service

Getting Error: http: read on closed response body from Transaction Processor function in Hyperledger Composer

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've a fabric network running with a simple BNA. This BNA defines two types of participants viz. Corporate and Person. Here, each Person has a relationship with the corporate as shown below (cto file): participant Corporate identified by corporateId { o String corporateId o String corporateName } participant Person identified by personId { o String personId --> Corporate corporate } What I'm trying to do: Create a Corporate using Transaction Processor Function: Success Create a Person using Transaction Processor Function: Failure Following

Spring Data JPA and Exists query

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using Spring Data JPA (with Hibernate as my JPA provider) and want to define an exists method with a HQL query attached: public interface MyEntityRepository extends CrudRepository { @Query("select count(e) from MyEntity e where ...") public boolean existsIfBlaBla(@Param("id") String id); } When I run this query, I get a java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Boolean . How does the HQL query have to look like to make this work? I know I could simply return a Long value and afterwards check in my Java code

Find if Object Exists in Dbset

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a DbSet object DbSet<ShippingInformation> ShippingInformations; I have also overridden the equals operator for ShippingInformation. How can I find if there is an existing object, y in the set ShippingInformations that is equal to object x, both of type ShippingInformation . So far I have tried: storeDB.ShippingInformations.Contains(shippingInformation); However, that only works for primitive types. 回答1: Unfortunately you can't use your Equals implementation in a query to EF because it can't decompile your code to see how it's done.

C++ - Determining if directory (not a file) exists in Linux [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-03 01:22:25
This question already has answers here : Checking if a directory exists in Unix (system call) (5 answers) How would I determine if a directory (not a file) existed using C++ in Linux? I tried using the stat() function but it returned positive when a file was found. I only want to find if the inputted string is a directory, not something else. According to man(2) stat you can use the S_ISDIR macro on the st_mode field: bool isdir = S_ISDIR(st.st_mode); Side note, I would recommend using Boost and/or Qt4 to make cross-platform support easier if your software can be viable on other OSs. ayush how

Check if a specific mysql connection already exists during a php script?

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a class for each database table object. Each class takes care of connection/queries/data format (database table specific logic) as I prefer to assign a connection for each class for better modularity. Also, I am using specific connections for some tables and queries. My question is how can I check if a connection already exists so it won't start another one? Basically I want to check if the connection with the same username/password/database has already been made. Or is this not necessary because mySql won't start a new

Find if an item already exists in STL queue

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using an STL queue to implement a BFS (breadth first search) on a graph. I need to push a node in the queue if that node already doesn't exist in the queue. However, STL queue does not allow iteration through its elements and hence I cannot use the STL find function. I could use a flag for each node to mark them when they are visited and push them only when the flag is false, however, I need to run BFS multiple times and after each time I will have to reset all the flags, so I ended up using a counter instead of a flag, but I still

Unable to launch shortcut (lnk) files from 32-bit C# application when the full path resolves to a 64-bit directory

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to launch programs in the Start Menu from a C# application, and nearly all of the items in the Start Menu are shortcut (lnk) files. When using Process.Start to launch these files, I found that I was getting "The system cannot find the path specified" error if the full path of the lnk file pointed to the C:\Program Files directory. I did some research with File System Redirection in Windows, so I tried disabling it, but I'm still getting the same error: // disable file system redirection: IntPtr ptr = new IntPtr(); bool